相关疑难解决方法(0)

file_get_contents,空文件不能正常运行PHP

我尝试使用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

php file fgets file-get-contents

5
推荐指数
1
解决办法
8809
查看次数

标签 统计

fgets ×1

file ×1

file-get-contents ×1

php ×1