我尝试使用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";
Run Code Online (Sandbox Code Playgroud)
我的文件test.txt是空的.(0个八位字节).他存在,但他是空的.
当我写入内容时,我的代码完美无缺,但如果他是空的,我的代码回显"失败"
为什么呢,为什么他不能打开文件text.txt?