Search for string in php files (Including subdirectories)

While working on freelancing project, I was told to include a search functionality which would search all php file in a directory including its sub-directories. I used the file_get_contents function of PHP in this following way.