PHP头条
热点:

phpRename更改文件、文件夹名称


命令格式为:
bool rename ( string oldname, string newname [, resource context] )
  下面演示rename的具体应用:
文件位置如图:

目的:1.把cache.txt 更名为rename.txt;
2.将cache2.txt更名为cache3.txt
3.将html目录 更名为 cache
4.将file目录转移到html目录下(可以实现更名)
代码实现(有错误):
代码如下:
$file = "html/cache.txt";
$rename = "html/rename.txt";
if(rename($file,$rename)){
echo "更名成功";
}else{
echo "更名失败";
}
rename("html/cache2","html/cache3.txt");
rename("html","cache");
rename("file","html/files");
?>

常见错误分析:

检查语法,无问题;经查file目录不存在,导致错误。更为files编译成功

这个错误小啊,致命啊

www.phpzy.comtrue/php/12362.htmlTechArticlephpRename更改文件、文件夹名称 命令格式为: bool rename ( string oldname, string newname [, resource context] ) 下面演示rename的具体应用: 文件位置如图: 目的:1.把cache.txt 更名为rename.txt; 2.将cach...

相关文章

相关频道:

PHP之友评论

今天推荐