↑ ↓ select, Enter open, Esc close

Check all PHP files in a directory for syntax errors

Adjust the values, the command updates live
user@server
find /var/www/vhosts/example.com/httpdocs/wp-content/themes -name '*.php' -exec php -l {} \; 2>&1 | grep -v '^No syntax errors'

Runs the syntax check php -l on every .php file found, without executing the code. Only files with parse errors are printed. Useful before switching PHP versions or after manual changes to theme and plugin files.

Note: For a PHP upgrade, check with the target version, for example /opt/plesk/php/8.3/bin/php -l. The syntax check does not find runtime errors such as deprecated functions.

Also searched as

  • find php syntax errors
  • search for php parse error
  • lint php files before upgrade

Related one-liners

All in PHP

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.