Call
608.845.2900
Visit
330 Locust Dr.
Verona, WI 53593
Message
info@powderkegwebdesign.com
Powderkeg Web Design
Menu
Message Us
Nick
Nick

PHP, Error Reporting, and You

December 27, 2013

When developing in PHP, nothing is more frustrating than running your script and having nothing but a white screen come up. Your 73 lines of code that should echo out beautiful information were not meant to be suppressed with something that gives no indication of what could have gone wrong.

A quick way to enable error reporting in PHP is to put the following at the top of your script:

 This will output any errors or warnings that your code generates and usually what line number of your php file the error occurs instead of just showing you nothing. Now you will know when you’ve forgotten a semi colon or defined a global variable twice.

To remove error reporting, you would want to remove the lines you’ve added. If you don’t have access to the code that allows error reporting but you still want to remove it, you can alternatively add this to the top of your script:

It is important that you do not use the above code to ignore errors and warnings. Rather, you should use it in a production environment where you do not want potential malicious users to decipher sensitive information about your script. I always have error reporting on in my development environment so that I never push out erroneous code.

Further Reading: PHP error_reporting

Nick
Nick
Lead Developer

Nick is an ambitious and versatile developer with a wide range of talents. He is an efficient coder that utilizes his resources in order to achieve both his and the clients’ goals. His Alma Mater is the University of Wisconsin – Stevens Point where he graduated with honors in Web and Digital Media Development.