An in depth understanding of PHP Error and Logging functions

  • 2020-06-03 06:03:01
  • OfStack

About PHP Error and Logging
The error and logging functions allow you to handle and record errors.
The error function allows users to define error handling rules and modify how errors are logged.
The logging function allows users to log applications and send log messages to E-mail, system logs, or other machines.

The installation
The error and logging functions are part of the PHP core. These functions can be used without installation.
PHP Error and Logging functions

PHP: Indicates the earliest VERSION of PHP that supported this function.
The function describes PHP
debug_backtrace() generates backtrace. 4
debug_print_backtrace() output backtrace. 5
error_get_last() gets the last error that occurred. 5
error_log() sends an error to the server error record, file, or remote destination. 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() sets the user-defined error handling function. 4
set_exception_handler() sets a user-defined exception handler. 5
trigger_error() creates a user-defined error message. 4
user_error() trigger_error() alias. 4
PHP Error and Logging constants

PHP: Indicates the earliest version of PHP that supported this constant.
The value constant describes PHP
1 E_ERROR fatal runtime error. The error cannot be recovered. The execution of the script was interrupted.
2 E_WARNING non-fatal runtime error. The execution of the script will not be interrupted.
4 E_PARSE compile time syntax parsing error. Parsing errors should only be generated by the parser.
E_NOTICE runtime prompt. This can be an error, or it can occur while the script is running normally.
E_CORE_ERROR Error generated internally by PHP. 4
32 E_CORE_WARNING warning generated internally by PHP. 4
64 E_COMPILE_ERROR Error generated internally by the Zend scripting engine. 4
128 E_COMPILE_WARNING Warning generated internally by the Zend scripting engine. 4
256 E_USER_ERROR generated by calling the trigger_error() function. 4
512 E_USER_WARNING runtime warning generated by calling the trigger_error() function. 4
1024 E_USER_NOTICE runtime prompt generated by calling the trigger_error() function. 4
2048 E_STRICT runtime prompt. It is beneficial to enhance code interoperability and compatibility. 5
4096 E_RECOVERABLE_ERROR can catch fatal errors. (see set_error_handler()) 5
E_ALL All errors and warnings except E_STRICT. 5


Related articles: