English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

PHP Basic Tutorial

PHP Advanced Tutorial

PHP & MySQL

PHP Reference Manual

PHP Error & Loggings Error Handling and Logging Functions

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.

Installation

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

Run-time Configuration

The behavior of these functions is affected by the settings in php.ini. These settings are defined below.

NameDefaultChange Log
error_reportingNULL
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_stringNULL
error_append_stringNULL
error_logNULL
warn_plus_overloadingNULLSince PHP 4This option is no longer available from version .0.0

PHP Error and Logging Constants

Version-The earliest version of PHP that supports constants.

You can use any constant when configuring the php.ini file.

Values
Constants and declarationsVersion
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

Function list

P version-Represents the earliest PHP version that supports the function.

NumberFunctionDescription
Version
1debug_backtrace()Generate backtrace4
2debug_print_backtrace()Print backtrace5
3error_get_last()Get the last occurred error5
4error_log()Send errors to server error log, file, or remote destination4
5error_reporting()Specify which errors to report4
6restore_error_handler()Restore previous error handler4
7restore_exception_handler()Restore previous exception handler5
8set_error_handler()Set user-defined function to handle errors4
9set_exception_handler()Set user-defined function to handle exceptions5
10trigger_error()Create user-defined error messages4
11user_error()trigger_error() alias4