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

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

    extra_headers

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

  • 相关阅读:
    Android 请求运行时权限
    Android 调试技巧之快速重启生效
    ubuntu 用aptitude代替apt-get处理依赖性问题
    Learning Git by Animations
    Android调试技巧
    Android O PackageInstaller 解析
    阅读代码工具:Visual Studio Code
    Android 缓存策略demo
    |= 和 &= ~
    Android 逆向工具
  • 原文地址:https://www.cnblogs.com/gaogaoxingxing/p/5355207.html
Copyright © 2020-2023  润新知