
- PHP - Home
- PHP - Roadmap
- PHP - Introduction
- PHP - Installation
- PHP - History
- PHP - Features
- PHP - Syntax
- PHP - Hello World
- PHP - Comments
- PHP - Variables
- PHP - Echo/Print
- PHP - var_dump
- PHP - $ and $$ Variables
- PHP - Constants
- PHP - Magic Constants
- PHP - Data Types
- PHP - Type Casting
- PHP - Type Juggling
- PHP - Strings
- PHP - Boolean
- PHP - Integers
- PHP - Files & I/O
- PHP - Maths Functions
- PHP - Heredoc & Nowdoc
- PHP - Compound Types
- PHP - File Include
- PHP - Date & Time
- PHP - Scalar Type Declarations
- PHP - Return Type Declarations
- PHP - Operators
- PHP - Arithmetic Operators
- PHP - Comparison Operators
- PHP - Logical Operators
- PHP - Assignment Operators
- PHP - String Operators
- PHP - Array Operators
- PHP - Conditional Operators
- PHP - Spread Operator
- PHP - Null Coalescing Operator
- PHP - Spaceship Operator
- PHP Control Statements
- PHP - Decision Making
- PHP - If…Else Statement
- PHP - Switch Statement
- PHP - Loop Types
- PHP - For Loop
- PHP - Foreach Loop
- PHP - While Loop
- PHP - Do…While Loop
- PHP - Break Statement
- PHP - Continue Statement
- PHP Arrays
- PHP - Arrays
- PHP - Indexed Array
- PHP - Associative Array
- PHP - Multidimensional Array
- PHP - Array Functions
- PHP - Constant Arrays
- PHP Functions
- PHP - Functions
- PHP - Function Parameters
- PHP - Call by value
- PHP - Call by Reference
- PHP - Default Arguments
- PHP - Named Arguments
- PHP - Variable Arguments
- PHP - Returning Values
- PHP - Passing Functions
- PHP - Recursive Functions
- PHP - Type Hints
- PHP - Variable Scope
- PHP - Strict Typing
- PHP - Anonymous Functions
- PHP - Arrow Functions
- PHP - Variable Functions
- PHP - Local Variables
- PHP - Global Variables
- PHP Superglobals
- PHP - Superglobals
- PHP - $GLOBALS
- PHP - $_SERVER
- PHP - $_REQUEST
- PHP - $_POST
- PHP - $_GET
- PHP - $_FILES
- PHP - $_ENV
- PHP - $_COOKIE
- PHP - $_SESSION
- PHP File Handling
- PHP - File Handling
- PHP - Open File
- PHP - Read File
- PHP - Write File
- PHP - File Existence
- PHP - Download File
- PHP - Copy File
- PHP - Append File
- PHP - Delete File
- PHP - Handle CSV File
- PHP - File Permissions
- PHP - Create Directory
- PHP - Listing Files
- Object Oriented PHP
- PHP - Object Oriented Programming
- PHP - Classes and Objects
- PHP - Constructor and Destructor
- PHP - Access Modifiers
- PHP - Inheritance
- PHP - Class Constants
- PHP - Abstract Classes
- PHP - Interfaces
- PHP - Traits
- PHP - Static Methods
- PHP - Static Properties
- PHP - Namespaces
- PHP - Object Iteration
- PHP - Encapsulation
- PHP - Final Keyword
- PHP - Overloading
- PHP - Cloning Objects
- PHP - Anonymous Classes
- PHP Web Development
- PHP - Web Concepts
- PHP - Form Handling
- PHP - Form Validation
- PHP - Form Email/URL
- PHP - Complete Form
- PHP - File Inclusion
- PHP - GET & POST
- PHP - File Uploading
- PHP - Cookies
- PHP - Sessions
- PHP - Session Options
- PHP - Sending Emails
- PHP - Sanitize Input
- PHP - Post-Redirect-Get (PRG)
- PHP - Flash Messages
- PHP AJAX
- PHP - AJAX Introduction
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML
- PHP - XML Introduction
- PHP - Simple XML Parser
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Login Example
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP Advanced
- PHP - MySQL
- PHP.INI File Configuration
- PHP - Array Destructuring
- PHP - Coding Standard
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Try…Catch
- PHP - Bugs Debugging
- PHP - For C Developers
- PHP - For PERL Developers
- PHP - Frameworks
- PHP - Core PHP vs Frame Works
- PHP - Design Patterns
- PHP - Filters
- PHP - JSON
- PHP - Exceptions
- PHP - Special Types
- PHP - Hashing
- PHP - Encryption
- PHP - is_null() Function
- PHP - System Calls
- PHP - HTTP Authentication
- PHP - Swapping Variables
- PHP - Closure::call()
- PHP - Filtered unserialize()
- PHP - IntlChar
- PHP - CSPRNG
- PHP - Expectations
- PHP - Use Statement
- PHP - Integer Division
- PHP - Deprecated Features
- PHP - Removed Extensions & SAPIs
- PHP - PEAR
- PHP - CSRF
- PHP - FastCGI Process
- PHP - PDO Extension
- PHP - Built-In Functions
PHP - Error Handling Functions
These are functions dealing with error handling and logging. They allow you to define your own error handling rules, as well as modify the way the errors can be 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 machines, to an email, to system logs, etc., so you can selectively log and monitor the most important parts of your applications and websites.
Installation
The error and logging functions are part of the PHP core. There is no installation needed to use these functions.
Runtime Configuration
The behaviour of these functions is affected by settings in php.ini. These settings are defined below.
Name | Default | Changeable | Changelog |
---|---|---|---|
error_reporting | NULL | PHP_INI_ALL | |
display_errors | "1" | PHP_INI_ALL | |
display_startup_errors | "0" | PHP_INI_ALL | Available since PHP 4.0.3. |
log_errors | "0" | PHP_INI_ALL | |
log_errors_max_len | "1024" | PHP_INI_ALL | Available since PHP 4.3.0. |
ignore_repeated_errors | "0" | PHP_INI_ALL | Available since PHP 4.3.0. |
ignore_repeated_source | "0" | PHP_INI_ALL | Available since PHP 4.3.0. |
report_memleaks | "1" | PHP_INI_ALL | Available since PHP 4.3.0. |
track_errors | "0" | PHP_INI_ALL | |
html_errors | "1" | PHP_INI_ALL | PHP_INI_SYSTEM in PHP <= 4.2.3. Available since PHP 4.0.2. |
docref_root | "" | PHP_INI_ALL | Available since PHP 4.3.0. |
docref_ext | "" | PHP_INI_ALL | Available since PHP 4.3.2. |
error_prepend_string | NULL | PHP_INI_ALL | |
error_append_string | NULL | PHP_INI_ALL | |
error_log | NULL | PHP_INI_ALL | |
warn_plus_overloading | NULL | This option is no longer available as of PHP 4.0.0 |
PHP Error and Logging Constants
PHP − indicates the earliest version of PHP that supports the constant.
You can use any of the constant while configuring your php.ini file.
Value | Constant & Description | PHP |
---|---|---|
1 |
E_ERROR Fatal run-time errors. Errors that cannot be recovered from. Execution of the script is halted |
|
2 |
E_WARNING Non-fatal run-time errors. Execution of the script is not halted |
|
4 |
E_PARSE Compile-time parse errors. Parse errors should only be generated by the parser |
|
8 |
E_NOTICE Run-time notices. The script found something that might be an error, but could also happen when running a script normally |
|
16 |
E_CORE_ERROR Fatal errors at PHP startup. This is like an E_ERROR in the PHP core |
4 |
32 |
E_CORE_WARNING Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core |
4 |
64 |
E_COMPILE_ERROR Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine |
4 |
128 |
E_COMPILE_WARNING Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine |
4 |
256 |
E_USER_ERROR Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error() |
4 |
512 |
E_USER_WARNING Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error() |
4 |
1024 |
E_USER_NOTICE User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error() |
4 |
2048 |
E_STRICT Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code |
5 |
4096 |
E_RECOVERABLE_ERROR Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler()) |
5 |
8191 |
E_ALL All errors and warnings, except of level E_STRICT |
5 |
List of Functions
PHP − indicates the earliest version of PHP that supports the function.
Sr.No | Advanced & Description | PHP |
---|---|---|
1 |
debug_backtrace()
Generates a backtrace |
4 |
2 |
debug_print_backtrace()
Prints a backtrace |
5 |
3 |
error_clear_last()
Clear the most recent error |
7 |
4 |
error_get_last()
Gets the last error occurred |
5 |
5 |
error_log()
Sends an error to the server error-log, to a file or to a remote destination |
4 |
6 |
error_reporting()
Specifies which errors are reported |
4 |
7 |
restore_error_handler()
Restores the previous error handler |
4 |
8 |
restore_exception_handler()
Restores the previous exception handler |
5 |
9 |
set_error_handler()
Sets a user-defined function to handle errors |
4 |
10 |
set_exception_handler()
Sets a user-defined function to handle exceptions |
5 |
11 |
trigger_error()
Creates a user-defined error message |
4 |
12 |
user_error()
Alias of trigger_error() |
4 |