picaso

       rename()命令可以实现文件文件夹的更名操作,而且还可以实现文件、文件夹的移动操作,命令格式为:

       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目录下(可以实现更名)


代码实现(有错误):

<?php
$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编译成功

这个错误小啊,致命啊…………………………

分类:

技术点:

相关文章:

  • 2021-08-24
  • 2021-04-02
  • 2021-04-26
  • 2021-12-29
  • 2021-07-06
  • 2021-10-29
猜你喜欢
  • 2021-10-03
  • 2020-06-28
  • 2021-05-31
  • 2021-12-23
  • 2021-07-16
  • 2021-12-30
  • 2021-07-13
相关资源
相似解决方案