PHP学习笔记【17】--PHP错误日志

来源:互联网 发布:国际交流的软件 编辑:程序博客网 时间:2024/06/13 17:42

1,PHP错误日志

默认地,根据在php.in中的error_log配置,PHP向服务器的错误记录系统或文件发送错误记录,通过使用error_log()函数,您可以向指定的文件或远程的目的发送错误记录。

<?php

function my_error($errno,$errmes){

//\r\n是用来换行的

//time()返回时间戳,一个秒数从 1970,, 

//默认时区是UTC 和慢中国的时间8个小时

//设置时区 date_default_timezone_set(PRC);

// date("Y-m-d  G:i s")

date_default_timezone_set("PRC");

$errInfo=$errno."--".$errmes."\r\n".date("Y-m-d  G:i s");

error_log($errInfo,3,"error.txt");

}

set_error_handler("my_error",E_USER_WARNING);

trigger_error("无缘无语出错了",E_USER_WARNING);

?>

本文出自 “Kenan_ITBlog” 博客,请务必保留此出处http://soukenan.blog.51cto.com/5130995/1070651