简体   繁体   English

PHP file_put_contents() 的奇怪问题

[英]Weird issue with PHP file_put_contents()

Using PHP v5.6.40 under Ubuntu 18.04.04 (through php5.6 apache mod), this is the line of code:在Ubuntu 18.04.04下使用PHP v5.6.40(通过php5.6 apache mod),这是这行代码:

file_put_contents('/tmp/deploy.hook.log', date('Y-m-d H:i:s') . ': ' . $data . "\n", FILE_APPEND);

It works in every other server / environment I have set but not here for some reason, no PHP errors or permission issues;它适用于我设置的所有其他服务器/环境,但由于某种原因不在此处,没有 PHP 错误或权限问题; the function also returns the number of bytes written even though the file remains empty.即使文件保持为空,该函数也会返回写入的字节数。

Other interesting thing is that if I run the code using the php cli as www-data it works fine.另一个有趣的事情是,如果我使用 php cli 作为 www-data 运行代码,它工作正常。

Any thoughts?有什么想法吗?

看来 Sammitch 的评论是正确的,我真正的 /tmp 目录类似于 /tmp/systemd-private-{some-hash}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM