Wednesday, July 18, 2012

error_reporting() function in PHP



The default error report in PHP is off, You can turn on error reporting in php.ini,via chnaging:
display_errors = Off
to
display_errors = On

There are 14 levels of PHP errors, to include all levels of error messages except notice, change
error_reporting = E_ALL 
to
error_reporting = E_ALL & ~E_NOTICE

If we set error reporting off in php.ini, we still can turn it on in PHP code via:
adding the following code at the beginning of your PHP script

ini_set('display_errors', 1);
error_reporting(E_ALL);


The 14 evels of PHP errors are as follows:

1        E_ERROR          fatal, script stop
2        E_WARNING       not fatal. script continues  to be executed
4        E_PARSE         
8        E_NOTICE        
16       E_CORE_ERROR    
32       E_CORE_WARNING  
64       E_COMPILE_ERROR 
128      E_COMPILE_WARNING
256      E_USER_ERROR    
512      E_USER_WARNING 
1024     E_USER_NOTICE   
2048     E_STRICT     
4096     E_RECOVERABLE_ERROR
8191     E_ALL:     all erros and warnings。

No comments:

Post a Comment