【发布时间】:2018-03-25 18:53:43
【问题描述】:
我在两个 ubuntu 16.04 上运行 PHP 7.0.22,在 LAMP 下。
以下代码继续运行,不会引发异常,并且 $tempFile 的值为 Resource id #4。
try {
// Open temp file for writing
$tempFile = fopen("/var/www/dropbox/temp.lst", "w");
echo "tempfile=" . $tempFile . "<br>";
// Write list of file names to file
for ($x = 0; $x <= $inputFileCount; $x++) {
fwrite($tempFile, $fileNames);
}
// Close temp file
fclose($tempFile);
} catch ( Exception $e ) {
// send error message if you can
echo 'Caught exception: ', $e->getMessage(), "\n";
}
但是,名称为 temp.lst 的文件没有出现在具有完全写入权限的目录 /var/www/dropbox/ 中。
ls -ld /var/www/dropbox/
drwxrwsrwx 2 ubuntu www 4096 Mar 25 18:13 /var/www/dropbox/
没有错误,与代码相关,由
显示cat /var/log/apache2/error.log
【问题讨论】:
-
请注意:原生 PHP 文件系统函数不会抛出异常。您是否使用自定义错误处理程序?
-
@d3L 偷了我的话,我要补充一点,如果不是,您应该打开错误报告。
-
谢谢。我打开了错误报告。很有帮助!