logo

php inline error reporting on

logo

There are going to be times when you are faced with a blank screen and a wave of frustration! Welcome to web programming. I know C programmers are going to argue that the pitfalls of php programming are nothing when compared to segmentation faults and memory leaks, but never the less it is very frustrating when you are developing and PHP error reporting isn’t turned on.

Whenever I am faced with an empty white screen these days I already know there is a good chance there is a PHP error somewhere and that PHP error reporting is turned off. There are a couple of ways of turning this back on such as editing the php.ini file but this post is targeted at people wanting to turn on php error reporting in their code on the fly.
Please note that this code must be added before the actual error occurs or else you will still be faced with a blank page:

If you want to show all warnings as well as errors use this code:

ini_set(‘display_errors’,1);
error_reporting(E_ALL);

If you only want to see errors just use this code:

ini_set(‘display_errors’,1);
error_reporting(E_ALL|E_STRICT);

And last, but not least, if you are wanting to do the opposite and turn all error reporting you can add this line of code to your repository and you should see all errors disappear:

Leave a Reply

logo
logo
Powered by Wordpress | Designed by Elegant Themes