我试图用下面的代码用php编写一个文件
$filename = "uploads/stories/".$row['s_source'];
$handle = fopen($filename, "r");
if (filesize($filename) == 0) {
$txt = "{====views====}{====likes====}{====chapters====}{====comments====}";
fwrite($handle, $txt);
}
$content = fread($handle, filesize($filename));
fclose($handle);我得到了:
注意: fwrite():写入66个字节失败,errno=9坏文件描述符在第20行的E:\xampp\htdocs\host\host\storyedit.php中
警告: fread():在第22行的E:\xampp\htdocs\host\host\storyedit.php中,长度参数必须大于0
注意:未定义的偏移量:1在第27行的E:\xampp\htdocs\host\host\storyedit.php中
但是代码中没有错误(我认为)。有人能帮我吗?
我试过:
php.ini
中的
都没起作用。
发布于 2020-05-03 01:05:51
使用读取访问打开,然后给出需要使用读/写访问打开的写command>。
$handle = fopen($filename, "r+");关于fread中的错误,请尝试
if (filesize($filename) > 0) {
$content = fread($handle, filesize($filename));
}https://stackoverflow.com/questions/61568204
复制相似问题