Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP error_log() Function

PHP error_log() Function


PHP Error Reference Manual 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 log.
type Optional. Specifies the type of error logging.
 可能的记录类型:     
  • 0 - Default. Based on the error_log configuration in php.ini, the error is sent to the server logging system or to a file.
  • 1 - The error is sent to the address in the destination parameter. Only this type uses the headers parameter.
  • 2 - The error is sent through the PHP debugging connection. This option is only available in PHP 3.
  • 3 - The error is sent to the file destination string.
  • | | 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 email, a From header must be included. It can be set in the php.ini file or through this parameter.

    |

    Example

    The following example sends an email with a custom error:

    1) { error_log("A custom error has been triggered", 1,"someone@example.com","From: webmaster@example.com"); } ?>

    The email received by the code above is shown below:

    A custom error has been triggered


    PHP Error Reference Manual Complete PHP Error Reference Manual