Turn off error reporting on your production site

On a production site, you would most likely want to hide all possible PHP errors, warnings and notices from your users for both usability, presentational and security purposes. For development and debugging purposes, you would want to turn on error_reporting and display all error messages so that you can debug your code and ensure that it is working as intended. You have to remember that there are different types of PHP errors. Fatal errors literally cease the execution of the script while warnings and notices simply notify you of the possibility of errors or bad programming practice in general. In this article, I’ll use WordPress as an example. I’ll show you how to turn off error_reporting on your WordPress production site so that users won’t have to look at ugly errors/warnings on your pages. Even though I’ll be using WordPress as an example, this method can be applied to any other type of platform. Start off by opening up your “wp-config.php” file in any type of text editor. Just after the PHP opening tag, put the following two lines of code. error_reporting(0); @ini_set('display_errors', 0); The first line will tell PHP the level of error_reporting you want to set. Have a look at the PHP error_reporting manual for more details and information n the different levels you are able to set. The second line executes the ini_set function which modifies...

Read More