Display_errors setting and page level error reporting settingsPHP script can be set to display error messages or not by changing display_error setting to On or Off. This setting is available in php.ini file which is a server level setting so not available for shared hosting accounts. But this can be overridden and local settings can be applied to display error or not. While developing scripts it is advisable to keep the display all type of error reporting to fix the bugs and to develop portability of the script. However we should suppress error messages in production servers as it will expose various details of script and database details to users.
IN our php.ini file there is a setting saying
With this we can display all types of error and this can be changed to
This will not display any error message to visitors.
Local or script level settingsAt the script level of any php page we can set the value like this which will change the php.ini setting , here is an example.
This will give this error message
You may not like this error message to be displayed to your visitors so we can add error_reporting function like this.
No error message will be displayed with the above code.
Development environmentWe should display all types of errors in a development environment.