The error_log() function sends an error to the server error log, a file, or a remote destination.
The function returns TRUE if successful and FALSE if failed.
error_log(error,type,destination,headers)
parameter | describe |
---|---|
error | Required. The error message to log. |
type | Optional. Specifies the type of error logging. Possible record types: 0 - Default. Depending on the error_log configuration in the php.ini file, errors are sent to the server logging system or to a file. 1 - Errors are sent to the address in the destination parameter. Only this type uses the headers parameter. 2 - Send errors via PHP debugging connection. This option is only available in PHP 3. 3 - Error sent to file target string. |
destination | Optional. Specifies where to send error messages. 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 (rn). Note: When sending an email, the From header must be included. This can be set in the php.ini file or via this parameter. |
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]");}? >
The email received by the above code is as follows:
A custom error has been triggered