Función PHP error_log()
Ejemplo
Envíe mensajes de error al registro de errores del servidor web y a una cuenta de correo:
<?php
// Send error message to the server log if error connecting to the database
if (!mysqli_connect("localhost","bad_user","bad_password","my_db")) {
error_log("Failed to connect to database!", 0);
}
// Send email to administrator if we run out of FOO
if (!($foo = allocate_new_foo())) {
error_log("Oh no! We are out of FOOs!", 1, "[email protected]");
}
?>
Definición y uso
La función error_log() envía un mensaje de error a un registro, a un archivo oa una cuenta de correo.
Sintaxis
error_log(message, type, destination, headers);
Valores paramétricos
Parameter | Description |
---|---|
message | Required. Specifies the error message to log |
type | Optional. Specifies where the error message should go.
Possible values:
|
destination | Optional. Specifies the destination of the error message. This value depends on the value of the type parameter |
headers | Optional. Only used if the type parameter is set to 1. Specifies additional headers, like From, Cc, and Bcc. Multiple headers should be separated with a CRLF (\r\n) |
Detalles técnicos
Valor devuelto: | VERDADERO sobre el éxito. FALSO en falla |
---|---|
Versión PHP: | 4.0+ |
Caja fuerte binaria: | No |
Registro de cambios de PHP: | PHP 5.2.7: Se agregó el valor de 4 al parámetro de tipo |
Referencia de errores de PHP