Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

PHP Error and Logging functions


May 11, 2021 PHP


Table of contents


PHP Error and Logging functions

The Error and Logging functions are part of the PHP core and are not required to be installed.


Introduction to PHP Error and Logging

The Error and Logging functions allow you to process and log errors.

The Error function allows the user 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 messages, system logs, or other machines.


The configuration is performed

The error function is affected .ini php profile.

Error and log configuration options:

Parameters The default Describe The range can be modified
error_reporting Null Set the error level for PHP and return the current level (number or constant). PHP_INI_ALL
display_errors "1" This option sets whether the error message is displayed to the screen as part of the output, or is hidden from the user.
Note: This feature should not be used in an on-line production environment (used during development testing)
PHP_INI_ALL
display_startup_errors "0" Even if display_errors is set to on, the error message during PHP startup is not displayed. It is highly recommended that you set the display_startup_errors to off, except for debugging purposes. PHP_INI_ALL
log_errors "0" Set whether the error message that the script is running is logged in the server error log or error_log error log. Note that this is a specific configuration item related to the server. PHP_INI_ALL
log_errors_max_len "1024" Sets the log_errors bytes of the value of the computer. I n error_log adds information about the source of the error. T he default is 1024, and if set to 0, it means unlimited length. This length setting has a restrictive effect on logged errors, $php, and the errormsg. PHP_INI_ALL
ignore_repeated_errors "0" Duplicate information is not logged. Repeated errors must appear on the same line of code in the same file, unless the ignore_repeated_source set to true. PHP_INI_ALL
ignore_repeated_source "0" When duplicate messages are ignored, the source of the message is also ignored. When this setting is turned on, duplicate information does not record whether it is generated by different files or different source code lines. PHP_INI_ALL
report_memleaks "1" If this parameter is set to Off, the memory leak information is not displayed (in stdout or logs). PHP_INI_ALL
track_errors "0" If turned on, the last error will always be in the $php the variable s errormsg. PHP_INI_ALL
html_errors "1" Turn off the HTML tag in the error message. PHP_INI_ALL
PHP_INI_SYSTEM in PHP <= 4.2.3.
xmlrpc_errors "0" Turn off normal error reporting and format the error format to XML-RPC error messages. PHP_INI_SYSTEM
xmlrpc_error_number "0" Used as the value of the XML-RPC faultCode element. PHP_INI_ALL
docref_root "" The new error message format contains a reference page that describes the error specifically or describes the function that caused it to occur.
In order to provide a page of the manual, you can download the manual for the corresponding language on the OFFICIAL PHP website and set the URL to the local address in the ini.
If your local manual copy can be accessed using "/manual/" you can simply set docref_root /manual/.
You'll also need docref_ext set the suffix name that matches your local docref_ext, .html. Of course, you can also set an external reference address.
For example, you can set the docref_root-http://manual/en/or docref_root-"http://landonize.it/?how=url&theme=classic&filter=Landon" and url=http%3A%2F%2Fwww.php.net%2F"
PHP_INI_ALL
docref_ext "" See docref_root. PHP_INI_ALL
error_prepend_string Null The content that was output before the error message. PHP_INI_ALL
error_append_string Null The contents of the output after the error message. PHP_INI_ALL
error_log Null The file to which the setup script error will be logged. The file must be written by the web server user. PHP_INI_ALL

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 supports the function.

function describe PHP
debug_backtrace() Generate Backtrace. 4
debug_print_backtrace() Print backtrace. 5
error_get_last() Get the last mistake. 5
error_log() Send an error to the server error record, file, or remote target. 4
error_reporting() It is specified which error is reported. 4
restore_error_handler() Restore the previous error handler. 4
restore_exception_handler() Restore the previous exception handler. 5
set_error_handler() Set user-defined error handling functions. 4
set_exception_handler() Set user-defined exception handlers. 5
trigger_error() Create user-defined error messages. 4
user_error() The alias of Trigger_Error (). 4


PHP Error and Logging constants

PHP: Indicates the earliest version of PHP that supports this constant.

value constant describe PHP
1 E_ERROR Fatal errors at runtime.The error that cannot be repaired.Stop execution scripts.
2 E_WARNING Running a non-fatal error.No script is not stopped.
4 E_PARSE Analytical errors when compiling.Analysis errors should be generated only by the parser.
8 E_NOTICE Notice of runtime.Script discovery may be an error, but it is also possible to happen when you run the script.
16 E_CORE_ERROR Fatal errors in PHP startup.This is like the PHP core E_ERROR. 4
32 E_CORE_WARNING PHP is a non-fatal error at startup.This is like the PHP core E_WARNING. 4
64 E_COMPILE_ERROR Fatal errors when compiling.This is like e_ERROR generated by the Zend script engine. 4
128 E_COMPILE_WARNING Compile time with non-fatal errors.This is like E_WARNING generated by the Zend scripting engine. 4
256 E_USER_ERROR The fatal error generated by the user.This is like the E_ERROR generated by the programmer using the PHP function trigger_error (). 4
512 E_USER_WARNING User-generated non-fatal errors.This is like the E_WARNING generated by the programmer using the PHP function trigger_error (). 4
1024 E_USER_NOTICE The notification of the user generated.This is like the E_NOTICE generated by the programmer using the PHP function Trigger_Error (). 4
2048 E_STRICT Notice of runtime.PHP recommends that you change the code to increase the interoperability and compatibility of the code. 5
4096 E_RECOVERABLE_ERROR Captuable fatal mistakes.This is like an e_ERROR that can be captured by the user-defined handle (see set_error_handler ()). 5
6143 E_ALL All errors and warning levels, except E_STRICT (from PHP 6.0, E_STRICT will be part of E_ALL). 5

Next, this site will take you through the Filesystem function!