I am creating a search engine for our giant PHP codebase.
Given the path to the file, how can I determine with a certain degree of certainty whether the file is a text file or some other type? I would prefer not to resort to file extensions (for example, substr($filename, -3) or something stupid), since this is a Linux-based file system, so it all depends on the file extensions.
I am using RecursiveDirectoryIterator, so I have these methods too.
source share