但是这种是针对某个定义错误的函数才有效 函数外的错误无法记录
<?php
set_error_handler('errorHandler');
function errorHandler( $errno, $errstr, $errfile, $errline, $errcontext)
{
$content = "[time]:".date('Y-m-d H:i:S')."\n[errno]:".$errno."\n[errstr]:".$errstr."\n[errfile]:".$errfile."\n[errline]:".$errline."\n\n";
file_put_contents('./log.txt',$content,FILE_APPEND);
}
function a( )
{
asdfasdf; // oops
}
function b()
{
a();
}
b();
?>