Introduction to PHP Error and Logging
The error and logging functions allow you to process and record errors.
The error function allows you to define error handling rules and modify the method for recording errors.
The logging function allows you to record applications and send log messages to emails, system logs, or other machines.
Install
The error and logging functions are the core components of PHP. These functions can be used without installation.
PHP Error and Logging functions
PHP: indicates the earliest PHP version that supports this function.
Function Description PHP
Debug_backtrace () to generate backtrace. 4
Debug_print_backtrace () Outputs backtrace. 5
Error_get_last () to obtain the final error. 5
Error_log () sends an error to the server error log, file, or remote target. 4
Error_reporting () specifies which error to report. 4
Restore_error_handler () restores the previous error handler. 4
Restore_exception_handler () restores the previous exception handler. 5
Set_error_handler () is used to set custom error handling functions. 4
Set_exception_handler () is used to set custom exception handling functions. 5
Trigger_error () creates custom error messages. 4
The alias user_error () trigger_error. 4
PHP Error and Logging Constants
PHP: indicates the earliest PHP version that supports this constant.
Value constant description PHP
1 E_ERROR: Fatal runtime error. The error cannot be recovered. The execution of the script is interrupted.
2 E_WARNING non-fatal runtime error. Script execution is not interrupted.
4. Syntax Parsing error during E_PARSE compilation. Resolution errors should only be generated by the parser.
8 E_NOTICE prompt during running. It may be an error, or it may occur when the script runs properly.
16 E_CORE_ERROR is an internal error generated by PHP. 4
32 E_CORE_WARNING is an internal warning generated by PHP. 4
64 E_COMPILE_ERROR is an internal error generated by the Zend script engine. 4
128 E_COMPILE_WARNING warning generated by the Zend script engine. 4
256 E_USER_ERROR is caused by a running error generated by calling the trigger_error () function. 4
512 E_USER_WARNING indicates a runtime warning generated by calling the trigger_error () function. 4
1024 E_USER_NOTICE indicates the runtime prompt generated by calling the trigger_error () function. 4
2048 E_STRICT prompt during running. It is helpful for enhancing code interoperability and compatibility. 5
4096 E_RECOVERABLE_ERROR: a fatal error that can be captured. (See set_error_handler () 5
8191 all errors and warnings except E_STRICT. 5