Error reporting is useful for debugging purposes. As well, perhaps you have some unimportant PHP warning displaying on your website that you would like to remove. This article will show you how to both display and hide PHP errors and warnings from the user.
PHP Code to Display All Errors and Warning Messages
To display all warnings and notice this is an easy and simple way that should work in most hosting environments:
PHP Code to Turn See Warning Messages and Not Notices
PHP Code to Turn Off Error Reporting
Where to Place Code to Remove Errors and Warnings
You can place the bits of code above just about anywhere on in your PHP code but it has to be above the error or else you will not see any warnings or notices since the code is read from the top down.
Tip for WordPress Users: Place Code in Your wp-config.php File
To turn on or off error reporting site-wide then place the the lines of code above all other PHP in your WordPress site’s wp-config.php file located in your home directory.
PHP Error Reporting Via .htaccess File
If you prefer to use your .htaccess file then you can use the following code to display errors.
php_flag display_errors on
php_value error_reporting 7