PHP error reporting enables detailed implementation_PHP tutorial

WBOY
Release: 2016-07-13 10:54:22
Original
843 people have browsed it

php tutorial error reporting enabled detailed implementation

Definition and usage
error_reporting() sets the error reporting level of php and returns the current level.

Grammar
error_reporting(report_level) If the parameter level is not specified, the current error level will be returned. The following items are possible values ​​of level

*/
//Close all error reports
error_reporting(0);
//Only report running errors
error_reporting(e_error|e_warning|e_parse);
//Report e_notice
error_reporting(e_error|e_warning|e_parse|e_notice);
//Report all running errors except e_notice
//This is the default value of php.ini
error_reporting(e_all ^ e_notice);
//Report all php errors
error_reporting(e_all);
//Same effect as error_reporting(e_all), this setting will also report all php errors
ini_set('error_reporting', e_all);

/*

Value Constant Description
1 e_error fatal run-time errors. errors that can not be recovered from. execution of the script is halted
2 e_warning non-fatal run-time errors. execution of the script is not halted
4 e_parse compile-time parse errors. parse errors should only be generated by the parser
8 e_notice run-time notices. the script found something that might be an error, but could also happen when running a script normally
16 e_core_error fatal errors at php startup. this is like an e_error in the php core
32 e_core_warning non-fatal errors at php startup. this is like an e_warning in the php core
64 e_compile_error fatal compile-time errors. this is like an e_error generated by the zend scripting engine
128 e_compile_warning non-fatal compile-time errors. this is like an e_warning generated by the zend scripting engine
256 e_user_error fatal user-generated error. this is like an e_error set by the programmer using the php function trigger_error()
512 e_user_warning non-fatal user-generated warning. this is like an e_warning set by the programmer using the php function trigger_error()
1024 e_user_notice user-generated notice. this is like an e_notice set by the programmer using the php function trigger_error()
2048 e_strict run-time notices. php suggest changes to your code to help interoperability and compatibility of the code
4096 e_recoverable_error catchable fatal error. this is like an e_error but can be caught by a user defined handle (see also set_error_handler())
8191 e_all all errors and warnings, except level e_strict (e_strict will be part of e_all as of php 6.0)

*/

function unserialize_handler($errno,$errstr) //Custom function
{
echo "invalid serialized value.n"; //Output the specified content
}
$serialized='foo'; //Define string
set_error_handler('unserialize_handler'); //Set user-defined error message function
$original=unserialize($serialized); //Create php value from stored representation
restore_error_handler(); //Restore error information pointer

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632341.htmlTechArticlephp tutorial error report opens detailed implementation definition and usage error_reporting() sets the error level of php and returns the current level. Syntax error_reporting(report_level)If the parameter level...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!