PHP error_log() 函数

PHP 教程 · 2019-01-24 14:58:55

定义和用法

error_log() 函数向服务器错误记录、文件或远程目标发送一个错误。

如果成功该函数返回 TRUE,如果失败该函数返回 FALSE。

语法


error_log(error,type,destination,headers)


参数 描述
error 必需。要记录的错误消息。
type 可选。规定错误记录的类型。
可能的记录类型:
  • 0 - 默认。根据在 php.ini 文件中的 error_log 配置,错误被发送到服务器日志系统或文件。
  • 1 - 错误被发送到 destination 参数中的地址。只有该类型使用 headers 参数。
  • 2 - 通过 PHP debugging 连接来发送错误。该选项只在 PHP 3 中可用。
  • 3 - 错误发送到文件目标字符串。
destination 可选。规定向何处发送错误消息。该参数的值依赖于 "type" 参数的值。
headers 可选。只在 "type" 参数为 1 时使用。规定附加的头部,比如 From, Cc 以及 Bcc。附加头部由 CRLF (\r\n) 分隔。

注意:在发送电子邮件时,必须包含 From 头部。可以在 php.ini 文件中或者通过此参数设置。


实例

下面的实例发送一封带有自定义错误的电子邮件:


<?php
$test=2;
if ($test>1)
{
error_log("A custom error has been triggered",
1,"someone@example.com","From: webmaster@example.com");
}
?>

上面代码接收到的邮件如下所示:


A custom error has been triggered


点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Out of their Minds

Out of their Minds

Dennis Shasha、Cathy Lazere / Springer / 1998-07-02 / USD 16.00

This best-selling book is now available in an inexpensive softcover format. Imagine living during the Renaissance and being able to interview that eras greatest scientists about their inspirations, di......一起来看看 《Out of their Minds》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具