php rename() function
Translation results:
UK[ˌri:ˈneɪm] US[ˌriːˈneɪm]
vt. Rename..., change its name
Third person singular: renames Present participle: renaming Past tense: renamed Past participle: renamed
php rename() functionsyntax
Function:Rename files or directories.
Syntax: rename(oldname,newname,context)
##Parameters:
Description | |
Required. Specifies the file or directory to be renamed. | |
Required. Specifies the new name of the file or directory. | |
Optional. Specifies the environment for a file handle. context is a set of options that modify the behavior of the stream. |
Note: The encapsulation protocol used in oldname must match the one used in newname.
php rename() functionexample
<?php $file = "test.txt"; $res = rename($file,"index.txt"); if($res) { echo "文件重命名成功"; }else{ echo "文件重命名失败"; } ?>
Run instance »
Click the "Run instance" button to view the online instance