Dav*_*ker 5 php error-handling
我正在编写一个脚本,读取HTML模板文件,用数据填充它,然后将填充的HTML文件保存为缓存文件夹中的缓存副本.
我在评估fopen()运行时错误被抑制时是否出现错误时遇到了真正的困难:
$file = @fopen($location,"w+");
// manual states fopen() returns false on error
// though the below does not catch any errors
if (!$file) {
$this->doSomething();
}
Run Code Online (Sandbox Code Playgroud)
抑制是否对我不利?我真的很感激对此的一些见解.我试过设置error_reporting显示没有错误,
ini_set('display_errors',0);
ini_set('log_errors',1);
error_reporting(E_ALL);
Run Code Online (Sandbox Code Playgroud)
并取消了抑制,fopen()但无济于事.
你的代码应该可以工作。如果您从未输入该if语句并且没有触发任何错误,则文件已成功打开。为什么确定fopen()通话失败?