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() function syntax

Function:Rename files or directories.

Syntax: rename(oldname,newname,context)

##Parameters:

ParametersDescriptionoldnameRequired. Specifies the file or directory to be renamed. newnameRequired. Specifies the new name of the file or directory. contextOptional. 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() function example

<?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