Php 发生错误时,“打开文本文件”不会自动引发错误

Php 发生错误时,“打开文本文件”不会自动引发错误,php,exception,exception-handling,error-handling,throw,Php,Exception,Exception Handling,Error Handling,Throw,运行时发生错误时不要抛出错误؟ 例如,fwrite$logFile$errorMsg不存在$errorMsg 或者不存在dirname\uuuu文件。\uuuu.'\a\logError.txt 在这段代码中没有运行er和运行缓存 将显示php默认消息 function er() { echo "error....."; } try { set_exception_handler('er'); $logFile=fopen(dirname(__FIL

运行时发生错误时不要抛出错误؟

例如,fwrite$logFile$errorMsg不存在$errorMsg

或者不存在dirname\uuuu文件。\uuuu.'\a\logError.txt

在这段代码中没有运行er和运行缓存

将显示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

那么,试一试{}抓{}有什么好处呢?

lol什么?你的问题没有意义…我想在出错时显示我的消息