Just another blog?

How to enable error reporting in PHP without editing php.ini?

If your website is on a shared hosting and can’t edit your php configuration, or you just want to do a quick debugging for your php script on a production server, you can use the error_reporting function in php:


From php.net:

int error_reporting ([ int $level ] )

The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script. If the optional level is not set, error_reporting() will just return the current error reporting level.

In order to use this function, just put it on the top of your script while specifying the error reporting level:

Turn on all error reporting:

// OR
// OR
ini_set('error_reporting', E_ALL);

Turn off all error reporting:


Turn on specific error reporting levels:

// Report all errors except E_NOTICE:
error_reporting(E_ALL ^ E_NOTICE);

Now if display_errors is turned off in php configuration file, errors will not be displayed on the page even if you’re using error_reporting method , so you need to enable display_errors first with ini_set:



3 thoughts on “How to enable error reporting in PHP without editing php.ini?

  • Backgammon says:

    Well, I do not know if that is going to work for me, but definitely worked for you! Excellent post!

  • warez scene says:

    This kind of web site post listing features a huge amount of superb info. It’s exciting to look for a index that might draw in countless persons. Make sure you always keep writing, I am excited for the next document.

  • meg43tr44gi joe says:

    Heya, Thank you just for that brilliant article! I must bookmark HighND.com. Regards.

Leave a Reply to meg43tr44gi joe Cancel reply

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


× 7 = thirty five

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=""> <strike> <strong>