WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

PHP 5 Error Functions


PHP Error Introduction

The blunder capacities are utilized to manage mistake dealing with and logging.

The mistake capacities enable us to characterize claim blunder taking care of standards, and adjust the manner in which the blunders can be logged.

The logging capacities enable us to send messages straightforwardly to different machines, messages, or framework logs.

The mistake revealing capacities enable us to tweak what level and sort of blunder criticism is given.


Installation

The PHP blunder capacities are a piece of the PHP center. No establishment is required to utilize these functions.


Runtime Configuration

The conduct of the mistake capacities is influenced by settings in php.ini.

Errors and logging setup options:

Name Default Description Changeable
error_reporting NULL Sets the mistake revealing dimension (either a whole number or  named constants) PHP_INI_ALL
display_errors "1" Specifies whether mistakes ought to be printed to the screen, or in the event that they ought to be avoided the user.
Note: This element ought to never be utilized on generation frameworks (just to help your development)
PHP_INI_ALL
display_startup_errors "0" Even when display_errors is on, mistakes that happen amid PHP's startup arrangement are not displayed
Note: It is unequivocally prescribed to keep display_startup_errors off, aside from debugging
PHP_INI_ALL
log_errors "0" Defines whether content mistake messages ought to be logged to the server's mistake log or error_log.
Note: It is emphatically encouraged to use mistake logging rather than blunder showing on creation web sites
PHP_INI_ALL
log_errors_max_len "1024" Sets the greatest length of log_errors in bytes. The esteem "0" can be used to not make a difference any most extreme length whatsoever. This length is connected to logged mistakes, showed blunders, and furthermore to $php_errormsg (accessible since PHP 4.3) PHP_INI_ALL
ignore_repeated_errors "0" Specifies whether to log rehashed mistake messages. At the point when set to "1" it won't log blunders with rehashed mistakes from a similar document on a similar line (accessible since PHP 4.3) PHP_INI_ALL
ignore_repeated_source "0" Specifies whether to log rehashed blunder messages. At the point when set to "1" it won't log mistakes with rehashed blunders from various documents or source lines (accessible since PHP 4.3) PHP_INI_ALL
report_memleaks "1" If set to "1" (the default), this parameter will demonstrate a report of memory releases recognized by the Zend memory chief (accessible since PHP 4.3) PHP_INI_ALL
track_errors "0" If set to "1", the last blunder message will dependably be available in the variable $php_errormsg PHP_INI_ALL
html_errors "1" Turns off HTML labels in blunder messages PHP_INI_ALL
PHP_INI_SYSTEM in PHP <= 4.2.3.
xmlrpc_errors "0" Turns off typical mistake detailing and arrangements blunders as XML-RPC mistake message (accessible since PHP 4.1) PHP_INI_SYSTEM
xmlrpc_error_number "0" Used as the estimation of the XML-RPC faultCode component (accessible since PHP 4.1) PHP_INI_ALL
docref_root "" (available since PHP 4.3) PHP_INI_ALL
docref_ext "" (available since PHP 4.3.2) PHP_INI_ALL
error_prepend_string NULL Specifies a string to yield before a mistake message PHP_INI_ALL
error_append_string NULL Specifies a string to yield after a mistake message PHP_INI_ALL
error_log NULL Specifies the name of the record where content blunders ought to be logged. The record ought to be writable by the web server's client. On the off chance that the extraordinary esteem syslog is utilized, the blunders are sent to the framework lumberjack instead PHP_INI_ALL

PHP Error and Logging Functions

Function Description
debug_backtrace() Generates a backtrace
debug_print_backtrace() Prints a backtrace
error_get_last() Returns the last blunder that occurred
error_log() Sends a blunder message to a log, to a document, or to a mail account
error_reporting() Specifies which blunders are reported
restore_error_handler() Restores the past blunder handler
restore_exception_handler() Restores the past special case handler
set_error_handler() Sets a client characterized mistake handler function
set_exception_handler() Sets a client characterized special case handler function
trigger_error() Creates a client level mistake message
user_error() Alias of trigger_error()

PHP 5 Predefined Error and Logging Constants

Value Constant Description
1 E_ERROR Fatal run-time mistakes. Mistakes that can't be recuperated from. Execution of the content is halted
2 E_WARNING Run-time alerts (non-lethal blunders). Execution of the content isn't halted
4 E_PARSE Compile-time parse mistakes. Parse mistakes should just be created by the parser
8 E_NOTICE Run-time takes note. The content discovered something that may be a blunder, however could likewise happen when running a content normally
16 E_CORE_ERROR Fatal blunders at PHP startup. This resembles E_ERROR, with the exception of it is created by the center of PHP
32 E_CORE_WARNING Non-deadly mistakes at PHP startup. This resembles E_WARNING, aside from it is created by the center of PHP
64 E_COMPILE_ERROR Fatal incorporate time mistakes. This resembles E_ERROR, with the exception of it is produced by the Zend Scripting Engine
128 E_COMPILE_WARNING Non-deadly order time mistakes. This resembles E_WARNING, aside from it is created by the Zend Scripting Engine
256 E_USER_ERROR Fatal client created mistake. This resembles E_ERROR, with the exception of it is produced in PHP code by utilizing the PHP work trigger_error()
512 E_USER_WARNING Non-deadly client created cautioning. This resembles E_WARNING, aside from it is created in PHP code by utilizing the PHP work trigger_error()
1024 E_USER_NOTICE User-created take note. This resembles E_NOTICE, with the exception of it is produced in PHP code by utilizing the PHP work trigger_error()
2048 E_STRICT Enable to have PHP recommend changes to your code which will guarantee the best interoperability and forward similarity of your code (Since PHP 5 be that as it may, excluded in E_ALL until PHP 5.4)
4096 E_RECOVERABLE_ERROR Catchable deadly mistake. Shows that a presumably hazardous mistake happened, yet did not leave the Engine in an insecure state. On the off chance that the blunder is not gotten by a client characterized handle, the application prematurely ends as it was an E_ERROR (Since PHP 5.2)
8192 E_DEPRECATED Run-time takes note. Empower this to get alerts about code that will not work in future variants (Since PHP 5.3)
16384 E_USER_DEPRECATED User-produced cautioning message. This resembles E_DEPRECATED, with the exception of it is created in PHP code by utilizing the PHP work trigger_error() (Since PHP 5.3)
32767 E_ALL Enable all PHP mistakes and alerts (aside from E_STRICT in forms < 5.4)