rename() public method

Rename (or move) a file
public rename ( string $old_file, string $new_file, boolean $move = FALSE ) : boolean
$old_file string
$new_file string
$move boolean
return boolean
Example #1
0
 //处理远程目录旧文件
 for ($i = 0; $i < count($filelist); $i++) {
     echo str_pad('', 4096);
     ob_flush();
     flush();
     if ($example->list_files($filelist[$i] . '.bak')) {
         $example->delete_file($filelist[$i] . '.bak');
         $logmessage = "MESSAGE: 远程文件 " . $filelist[$i] . '.bak' . " 删除成功!\n<br/>";
         echo $logmessage;
         $example->add_log($logmessage);
     } else {
         $logmessage = "DELETE:  没有 " . $filelist[$i] . '.bak' . " 或删除失败! \n<br/>";
         $example->add_log($logmessage);
     }
     if ($example->list_files($filelist[$i])) {
         if (!$example->rename($filelist[$i], $filelist[$i] . '.bak')) {
             $logmessage = "RENAME : 文件 " . $filelist[$i] . "   重命名失败!\n<br/>";
             $example->add_log($logmessage);
             unset($filelist[$i]);
         } else {
             //将备份的文件记入日志,上线时统一删除
             $example->add_log($filelist[$i] . '.bak' . "\n<br/>", 'remotebackup.log');
         }
     } else {
         $logmessage = "MESSAGE: 文件  " . $filelist[$i] . "  不存在或者是新添加的。\n<br/>";
         $example->add_log($logmessage);
     }
 }
 //同步本地目录到远程
 for ($i = 0; $i < count($filelist); $i++) {
     echo str_pad('', 4096);