Php/func error log
来自菜鸟教程
PHP error_log()函数
例
将错误消息发送到Web服务器的错误日志和邮件帐户:
<?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, "admin@example.com");
}
?>
定义和用法
error_log()函数将错误消息发送到日志,文件或邮件帐户。
句法
error_log(message, type, destination, headers);
参数值
| 参数 | 描述 |
|---|---|
| message | 需要。指定要记录的错误消息 |
| type |
可选的。指定错误消息应该去的地方。可能的值:
|
| destination | 可选的。指定错误消息的目的地。此值取决于
type 参数 |
| headers | 可选的。仅在
type 参数设置为1。指定其他标头,例如From,Cc和Bcc。多个标头应以CRLF(\ r \ n)分隔 |
技术细节
| 返回值: | 成功则为真。失败时为假 |
| PHP版本: | 4.0+ |
| 二进制安全: | No |
| PHP更新日志: | PHP 5.2.7:将值4添加到了
type 参数 |