PHP show errors

If your page shows up blank after saving some changes, then your server is probably set to suppress error messages by default.

Add the following code to the beginning of the php file (don’t forget to remove it after you’re done):

  ini_set('display_errors', '1');

Note that this won’t help in cases of serious syntax errors. This is because syntax errors would prevent the PHP parser to execute the page – including any directives to start showing errors.

To fix that, you should either edit your php.ini, or, as you sometimes lack access to your php.ini (have you tried looking at the control panel administrator website page of your hosting company though?), or see it as a non-viable solution as those changes are global, there is another trick you can try.

Create a new file with the following contents:

  ini_set("display_errors", 1);

In this case, the new file is parsed correctly, and the PHP engine is set to display any error (including syntax errors) it encounters. The script subsequently includes the PHP page that contains errors, about which the PHP engine will now output relevant information.

Also, you can direct PHP to show errors in the .htaccess file in the relevant folder (just append it to the existing file – if it doesn’t exist, make a new one with the following contents):

php_value display_errors 1
php_value display_startup_errors 1

Also, thanks to Reddit user lostrootpass for pointing out that E_ALL|STRICT should be used when debugging.