English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
These are functions for handling error handling and logging. They allow you to define your own error handling rules and modify the way errors are logged. This allows you to change and enhance error reporting to suit your needs.
Using these logging functions, you can send messages directly to other computers, email, system logs, etc., so you can selectively log and monitor the most important parts of your applications and websites.
Error and logging functions are part of the PHP core. These functions can be used without installation.
The behavior of these functions is affected by the settings in php.ini. These settings are defined below.
Name | Default | Change Log |
---|---|---|
error_reporting | NULL | |
display_errors | "1" | |
display_startup_errors | "0" | Since PHP 4.0.3Available starting from version . |
log_errors | "0" | |
log_errors_max_len | "1024" | Since PHP 4.3Available starting from version .0. |
ignore_repeated_errors | "0" | Since PHP 4.3Available starting from version .0. |
ignore_repeated_source | "0" | Since PHP 4.3Available starting from version .0. |
report_memleaks | "1" | Since PHP 4.3Available starting from version .0. |
track_errors | "0" | |
html_errors | "1" | PHP <= 4.2.3In PHP_INI_SYSTEM since PHP 4.0.2Available starting from version . |
docref_root | "" | Since PHP 4.3Available starting from version .0. |
docref_ext | "" | Since PHP 4.3.2Available starting from version . |
error_prepend_string | NULL | |
error_append_string | NULL | |
error_log | NULL | |
warn_plus_overloading | NULL | Since PHP 4This option is no longer available from version .0.0 |
Version-The earliest version of PHP that supports constants.
You can use any constant when configuring the php.ini file.
Values | Constants and declarations | Version |
---|---|---|
1 | E_ERROR Fatal run-time error. Unrepairable error. The script execution is paused | |
2 | E_WARNING Non-fatal run-time error. The script execution will not stop | |
4 | E_PARSE Compile-time parse error. Parse errors should only be generated by the parser | |
8 | E_NOTICE Run-time notice. The script found content that might be erroneous, but it may also occur during normal script execution | |
16 | E_CORE_ERROR A fatal error occurred when PHP was started. This is like E_ERROR in the PHP core | 4 |
32 | E_CORE_WARNING Non-fatal errors occur at PHP startup. Like E_WARNING in the PHP core | 4 |
64 | E_COMPILE_ERROR Fatal compile-time errors. Like E_ERROR generated by the Zend script engine | 4 |
128 | E_COMPILE_WARNING Non-fatal compile-time errors. Like E_WARNING generated by the Zend script engine | 4 |
256 | E_USER_ERROR User-generated fatal errors. Like E_ERROR set by the programmer using PHP function trigger_error() | 4 |
512 | E_USER_WARNING Non-fatal user-generated warnings. Like E_WARNING set by the programmer using PHP function trigger_error() | 4 |
1024 | E_USER_NOTICE User-generated notifications. Like E_NOTICE set by the programmer using PHP function trigger_error() | 4 |
2048 | E_STRICT Run-time notification. PHP recommends changing your code to help code interoperability and compatibility | 5 |
4096 | E_RECOVERABLE_ERROR Catchable fatal errors. This is like an E_ERROR, but can be caught by a user-defined handler (see also set_error_handler() ) | 5 |
8191 | E_ALL All errors and warnings except E_STRICT level | 5 |
P version-Represents the earliest PHP version that supports the function.
Number | Function | Description | Version |
---|---|---|---|
1 | debug_backtrace() | Generate backtrace | 4 |
2 | debug_print_backtrace() | Print backtrace | 5 |
3 | error_get_last() | Get the last occurred error | 5 |
4 | error_log() | Send errors to server error log, file, or remote destination | 4 |
5 | error_reporting() | Specify which errors to report | 4 |
6 | restore_error_handler() | Restore previous error handler | 4 |
7 | restore_exception_handler() | Restore previous exception handler | 5 |
8 | set_error_handler() | Set user-defined function to handle errors | 4 |
9 | set_exception_handler() | Set user-defined function to handle exceptions | 5 |
10 | trigger_error() | Create user-defined error messages | 4 |
11 | user_error() | trigger_error() alias | 4 |