【发布时间】:2021-12-23 18:55:02
【问题描述】:
多次调用PHP函数fileperms时,似乎文件权限显示不正确了:
chmod('file.txt', 0600);
if ((fileperms('file.txt') & 0777) === 0600) {} // this is true
chmod('file.txt', 0660);
if ((fileperms('file.txt') & 0777) === 0660) {} // this is false
chmod('file.txt', 0666);
if ((fileperms('file.txt') & 0777) === 0666) {} // this is false
文件的权限已更改,但对 fileperms 的调用显示了不同的值。是否发生了一些缓存?
【问题讨论】:
-
$file.txtvsfile.txt? -
Tnx,更正了!
-
另外,你所有的 if 语句在语法上都是不正确的。
(fileperms(file.txt) & 0777) === 0666)你的括号不均匀(共5个) -
Tnx,再次更正
-
该代码应该触发多个警告,除非您在任何地方定义了常量
file和txt
标签: php file-permissions chmod