SQL PHP HTML ASP JavaScript articles and free scripts to download
 

Display_errors setting and page level error reporting settings

PHP 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

display_errors = On

With this we can display all types of error and this can be changed to

Display_errors=Off

This will not display any error message to visitors.

Local or script level settings

At 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.

<?Php
$one = $two;
?>

This will give this error message

Notice: Undefined variable: two in J:\php_files\t\error\test.php on line 13

You may not like this error message to be displayed to your visitors so we can add error_reporting function like this.

<?Php
error_reporting(0);// With this no error reporting will be there
$one = $two;
?>

No error message will be displayed with the above code.


Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked

Join Our Email List
Email:  
For Email Newsletters you can trust
PDO
PHP Sections