我试图重命名目录:重命名目录 - 创建一个新的(空)上
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的内部缓存有关。尝试http://tw.php.net/manual/en/function.clearstatcache.php – Basti 2012-02-23 12:33:56