【发布时间】:2012-03-13 20:38:00
【问题描述】:
我正在尝试重命名目录:
rename("billeder/123", "billeder/abc");
紧接着我修改了目录中一个文件的内容:
$s = file_get_contents("billeder/abc/fil.txt"); // note: using the new directory name (abc)!
$s = str_replace( "123", "abc", $s);
file_put_contents("billeder/abc/fil.txt", $s);
结果很奇怪:文件内容被修改了,OK!
- 但它仍然位于旧目录 (123) 中,并创建了一个新的空目录 (abc) ?!?!
PS:
- 目录 is_writable()
- 我在一个 linux 服务器上(Ubuntu,一切都是最新的)
- 我已经尝试在 rename() 中使用完整路径 - 没有区别。
- 我尝试在名称末尾添加 / 没有区别。
- 我尝试先修改文件,然后再重命名目录 - 仍然没有区别。
变得绝望.. 谁能弄清楚发生了什么?
【问题讨论】:
-
这可能与 PHP 在处理文件时的内部缓存有关。试试tw.php.net/manual/en/function.clearstatcache.php