Renames a file or directory
Syntax
rename ( string $oldname , string $newname [, resource $context ] ) : bool
Parameters
oldname
The old name.
Note: The wrapper used in oldname must match the wrapper used in newname.
newname
The new name.
Note: On Windows, if newname already exists, it must be writable. Otherwise rename() fails and issues E_WARNING.
context
Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Streams.
Return
Returns TRUE on success or FALSE on failure.
Examples
1 · oldname newname
<? $oldname = "/old/directory/oldfile.txt"; $newname = "/new/directory/newfile.txt"; $return = rename($oldname, $newname); var_export($return); ?>
true