php error_log() 范例

<?php
// 如果无法连接到数据库,发送通知到服务器日志
if (!Ora_Logon($username$password)) {
    error_log("Oracle database not available!"0);
}

// 如果用尽了 FOO,通过邮件通知管理员
if (!($foo allocate_new_foo())) {
    error_log("Big trouble, we're all out of FOOs!"1,
               "operator@example.com");
}

// 调用 error_log() 的另一种方式:
error_log("You messed up!"3"/var/tmp/my-errors.log");
?>
 

error_log() 是发送错误信息到某个地方的一个函数,在程序编程中比较常见,尤其是在程序调试阶段。

 bool error_log ( string $message [, int $message_type = 0 [, string $destination [, string $extra_headers ]]] ) 

把错误信息发送到 web 服务器的错误日志,或者到一个文件里。

message

应该被记录的错误信息。信息长度限制:The default seem to be 1024 but can be changed by adjusting the value of the runtime configuration value of ‘log_errors_max_len‘

message_type

设置错误应该发送到何处。可能的信息类型有以下几个:

error_log() 日志类型
0message 发送到 PHP 的系统日志,使用 操作系统的日志机制或者一个文件,取决于 error_log 指令设置了什么。 这是个默认的选项。
1message 发送到参数 destination 设置的邮件地址。 第四个参数 extra_headers 只有在这个类型里才会被用到。
2不再是一个选项。
3message 被发送到位置为 destination 的文件里。 字符 message 不会默认被当做新的一行。
4message 直接发送到 SAPI 的日志处理程序中。
destination

目标。它的含义描述于以上,由 message_type 参数所决定。

extra_headers

额外的头。当 message_type 设置为 1 的时候使用。 该信息类型使用了 mail() 的同一个内置函数。

转载于:https://www.cnblogs.com/gaogaoxingxing/p/5355207.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值