PHP Error and Logging Functions

63

PHP Error and Logging Introduction

The error and logging functions allows error handling and logging.

The error functions allow users to define error handling rules, and modify the way the errors can be logged.

The logging functions allow users to log applications and send log messages to email, system logs or other machines.


Installation

PHP Error and Logging Functions

The error and logging functions are part of the PHP core. There is no installation needed to use these functions.


PHP Error and Logging Functions

PHP: indicates the earliest version of PHP that supports the function.

FunctionDescriptionPHP
debug_backtrace()Generates a backtrace4
debug_print_backtrace()Prints a backtrace5
error_get_last()Gets the last error occurred5
error_log()Sends an error to the server error-log, to a file or to a remote destination4
error_reporting()Specifies which errors are reported4
restore_error_handler()Restores the previous error handler4
restore_exception_handler()Restores the previous exception handler5
set_error_handler()Sets a user-defined function to handle errors4
set_exception_handler()Sets a user-defined function to handle exceptions5
trigger_error()Creates a user-defined error message4
user_error()Alias of trigger_error()4

 


PHP Error and Logging Constants

PHP: indicates the earliest version of PHP that supports the constant.

ValueConstantDescriptionPHP
1E_ERRORFatal run-time errors. Errors that cannot be recovered from. Execution of the script is halted
2E_WARNINGNon-fatal run-time errors. Execution of the script is not halted
4E_PARSECompile-time parse errors. Parse errors should only be generated by the parser
8E_NOTICERun-time notices. The script found something that might be an error, but could also happen when running a script normally
16E_CORE_ERRORFatal errors at PHP startup. This is like an E_ERROR in the PHP core4
32E_CORE_WARNINGNon-fatal errors at PHP startup. This is like an E_WARNING in the PHP core4
64E_COMPILE_ERRORFatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine4
128E_COMPILE_WARNINGNon-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine4
256E_USER_ERRORFatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error()4
512E_USER_WARNINGNon-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error()4
1024E_USER_NOTICEUser-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error()4
2048E_STRICTRun-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code5
4096E_RECOVERABLE_ERRORCatchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler())5
6143E_ALLAll errors and warnings, except of level E_STRICT5
loading...
SHARE

LEAVE A REPLY