【发布时间】:2013-07-11 00:02:03
【问题描述】:
我尝试使用 PHP 的 file_get_contents 但它不起作用。
这是我的代码:
$filename = "/opt/gemel/test.txt";
if($filecontent = file_get_contents($filename)){
$nom = fgets(STDIN);
file_put_contents($filename, $nom, FILE_APPEND);
}
else
echo "fail";
我的文件 test.txt 是空的。 (0 个八位字节)。他存在,但他是空的。
当我在其中写入内容时,我的代码运行良好,但如果他为空,我的代码回显“失败”
为什么,为什么他不能打开文件text.txt?
【问题讨论】:
标签: php file file-get-contents fgets