So I made this file editor assignment for school and my teacher is well satisfied with the results. Yet he has one thing that he wants me to change:
At the moment I’m reading every file in a directory but im checking for each extension if I want to make it editable. That means I have to add an extension in the if statement each time a new extension needs to be added.
My teacher told me theres a function that returns true if the file is a text file like .html, .css, .php etc. and if its a .exe, .gif etc. it will return false. He’s too lazy to give me the name of the function.
So.. What’s the name of it? I’ve been trying to look it up but I just can’t find the name of the function..
Edit:
fine lol hes not lazy
Quote:
Try the finfo_file() function.
Here’s a blog describing its usage: Smart File Type Detection Using PHP
Taken from:
How can I tell if a file is text using PHP?