How can I tell if a file is text using PHP?

lalilo

New Member
I'm making a search engine for our gigantic PHP codebase.Given a filepath, how can I determine with some degree of certainty whether a file is a text file, or some other type? I'd prefer not to have to resort to file extensions (like \[code\]substr($filename, -3)\[/code\] or something silly), as this is a linux based filesystem, so anything goes as far as file extensions are concerned.I'm using RecursiveDirectoryIterator, so I have those methods available too..
 
Back
Top