代码如下:
$file = dirname(__FILE__).'/新建 文本文档.txt';
echo L_rename($file);
function L_rename($file){
$iCount = 0;
$File_type = strrchr($file, '.');
$FilePath = substr($file, 0, strrpos($file, '.'));
while (true) {
if (is_file($file)) {
++$iCount;
$file = $FilePath . '('. $iCount .')' . $File_type;
}else{
break;
}
}
if (fopen($file, 'w')) {$Msg = '创建成功 '.$file;}
return $Msg;
}
?>