我目前正在编写一个脚本,该脚本读取 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();
}
压制对我不利吗?我真的很感激对此有所了解。我试过设置 error_reporting
不显示错误,
ini_set('display_errors',0);
ini_set('log_errors',1);
error_reporting(E_ALL);
并从 fopen()
中删除了抑制,但无济于事。
最佳答案
您的代码应该可以工作。如果您从未输入 if
语句并且未触发任何错误,则文件已成功打开。为什么确定 fopen()
调用失败?
关于php - fopen() 错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7874388/