Linux/PHP one liner – Syntax check all files.

Here’s a simple one liner you can use to syntax check all php files in your working directory.

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

For those not familiar with the programs used, it basically reads as…. Find all files that end in ‘.php’ and with each of those files run php -l. This is then put through a pipe to the grep -v, which filters out all files that are syntactically correct.

  • Digg
  • del.icio.us
  • NewsVine
  • Reddit
  • Furl
  • DZone
  • StumbleUpon
  • Technorati

Tags: , , , ,


One Response to “Linux/PHP one liner – Syntax check all files.”

  1. frann Says:

    This looks really useful. I’m getting a nofind on php though, where does this script come from?

Leave a Reply