Debugging PHP Files From The Command Line

Here’s a handy tip for debugging PHP files when all you get is a blank white screen. You know something is wrong, but it isn’t telling you what. This is a common problem when editing custom template files for WordPress.

Error output can be configured by modifying the php.ini file, but this may not always be accessible. Another way to have PHP tell you where it’s having a problem is by going to the command line and running it there:

    $ php -l report.php 
    Parse error: parse error in report.php on line 834
    Errors parsing report.php

There it is: “line 834”. It’s a quick and simple solution, and should work for just about any PHP file.