Force PHP to show all errors

Many times I came across the question why the errors in PHP don’t show up and only a blank pages is served. It can be very annoying when developing a huge app and when you want to test something.

Sometimes errors won’t even appear when you set all directives to the right values. For example when writing something before “namespace”. (Exception the “declare” keyword.)

PHP has not only runtime options to omit errors.
But in the most casesĀ the following code will bring them back to you:

error_reporting(E_ALL);
ini_set('display_errors', 1);

An other option is to set a .htaccess directive in the folder of your PHP script in which you want to see errors:

php_flag display_errors 0

When nothingĀ seems to work, you will need to go into your PHP ini settings and search for the error reporting section:

error_reporting
and
display_errors

Also, look out for the following code. When it appears, it will override the error_reporting() settings:

set_error_handler();

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>