Enable error reporting and display PHP errors

If you’re likely to be on stackoverflow.com, you may often encounter people asking for help on a PHP problem where a script stops without an error message.

This is because the defaults changed with newer PHP versions not to be in debug mode on starting up.

Enable errors showing up in PHP:

 

Further debugging tricks:

– make use of print_r($var); to examine arrays or missing values
– declare your own error_handler http://php.net/set-error-handler
– take a look into the logs (most common: /var/log/apache/error.log)
– use the constant PHP_EOL instead of \n

Leave a Reply

Your email address will not be published. Required fields are marked *