PHP error_log()Functions
Complete PHP Error Reference Manual
Definition and Usage
The error_log() function sends an error to the server error log, a file, or a remote destination.
Returns TRUE on success, or FALSE on failure.
Syntax
error_log(error,type,destination,headers)
| Parameters | Description |
|---|---|
| error | Required. The error message to be logged. |
| type | Optional. Specifies the type of error logging. Possible logging types:
|
| destination | Optional. Specifies where to send the error message. The value of this parameter depends on the value of the "type" parameter. |
| headers | Optional. Only used when the "type" parameter is 1. Specifies additional headers, such as From, Cc, and Bcc. Additional headers are separated by CRLF (\r\n). Note:When sending an email, the From header must be included. It can be set in the php.ini file or through this parameter. |
Examples
The following example sends an email with a custom error:
<?php
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"[email protected]","From: [email protected]");
}
?>
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"[email protected]","From: [email protected]");
}
?>
The email received by the above code is as follows:
A custom error has been triggered
Complete PHP Error Reference Manual Other Extensions