Check PHP files syntax for list of files on Linux


Warning: Undefined array key "socialize_RedditWidget" in /home/phpacd/websites/shkodenko.com/wp-content/plugins/socialize/frontend/socialize-services.php on line 166

To check all PHP files syntax in current folders including subfolders you can use command like:

# find . -type f -name "*.php" -exec php -l {} \; | grep -v 'No syntax errors'

If you want to check few files syntax you can add them to some file e.g. /tmp/check-php-files-syntax.list and then run command below:

# for file in `cat /tmp/check-php-files-syntax.list`; php -l ${file}; done