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.
error_reporting() 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.
// Disable Error Reporting
error_reporting(0);
// 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
error_reporting(-1);
error_reporting(E_ALL);
// 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);
// Disable Error Reporting
error_reporting(0);
// 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
error_reporting(-1);
error_reporting(E_ALL);
// 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 E_STRICT mode in development environment. What you suggest?
Related Posts
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash