PHP Error Reporting

PHP has several types of errors to display, like Error, Warning, Notice, etc. PHP has given the control to developer for what types of errors should be displayed.

[code]error_reporting()[/code] function is used to set the error reporting level of the PHP web application. This function set the error reporting directive at run time.

We can set error reporting in various level with this function. Here are some example which may helps you.

[cc lang=”php”]

// Disable Error Reporting

// Only show Error, Warning, Notice and Parse Error
// We can place any combination over here.
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Show all Error Except Notice
error_reporting(E_ALL ^ E_NOTICE);

// Show all Errors

// Show All + Coding Standard Errors
error_reporting(E_ALL | E_STRICT);

// Suggested for Development Mode
error_reporting(E_ALL | E_STRICT);

// Suggested for Production Mode
error_reporting(E_ALL & ~E_DEPRECATED);

// Default value in PHP.ini
error_reporting(E_ALL & ~E_NOTICE);


I would strongly suggest to set the [code]E_STRICT[/code] mode in development environment. What you suggest?


Leave a Reply

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