PHP is_writable() 返回 true 但 file_put_contents() 返回 false

标签 php

即使 is_writable() 返回 true,我也无法写入文件。当然,该文件存在并且显然是可读的。这是代码:

$file = "data";
echo file_get_contents($file)."<br>";
echo is_writable($file) ? "is writable<br>" : "not writable<br>";
if (file_put_contents($file, "ghijkl", FILE_APPEND) === FALSE) echo "failed<br>";
echo file_get_contents($file)."<br>";

这是输出:

abcdef
is writable
failed
abcdef

最佳答案

所以只需要检查文件系统中的可用空间 就我而言 我在控制台输入:
df -h
文件系统大小已用可用容量安装在
/dev/da0s1f 4.3G 4.0G -68M 102%/usr

释放空间,然后函数 file_put_contents 开始工作

关于PHP is_writable() 返回 true 但 file_put_contents() 返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11238809/

相关文章:

php - mysql中基于特定条件的声明值

php/sql-如何在变量上使用 LIKE 运算符从数据库中提取结果?

php - PHP 中的 $bar = boolval($foo) 和 $bar = (bool) $foo 有什么区别?

php - 如何在 wooCommerce 插件中制作/嵌入我自己的产品展示设计

php - 使用 MySQLi 从 HTML 表单插入多行到数据库

php - 按范围 10 x 10 对数组进行排序

php - MySQL 查询合并两个表以获得单个结果

PHP 与 Javascript 访问数据库

php - 如何使用 php 或使用外部网站自动检测时区

php - PHP的内置函数在内部是如何实现的?