在运行时错误发生时不抛出错误吗?
例如$errorMsg
fwrite($logFile,$errorMsg);
或剂量不存在dirname(__FILE__).'\a\logError.txt
在此代码中没有运行er()
而没有运行cache
???
将显示php默认消息!
function er()
{
echo "error.....";
}
try
{
set_exception_handler('er');
$logFile=fopen(dirname(__FILE__).'\a\logError.txt','w');
fwrite($logFile,$errorMsg);
fclose($logFile);
}
catch(Exception $e)
{
echo $e->getMessage();
echo "catch";
}
Warning: fopen(C:\xampp\htdocs\HidariGold\a\logError.txt) [function.fopen]: failed to open stream: No such file or directory in C:\xampp\htdocs\HidariGold\test.php on line 35
Notice: Undefined variable: errorMsg in C:\xampp\htdocs\HidariGold\test.php on line 36
Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\HidariGold\test.php on line 36
Warning: fclose() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\HidariGold\test.php on line 37
那么try{}catch{}
??????????