(PHP 4, PHP 5, PHP 7)
Renames a file or directory
bool rename ( string $oldname, string $newname [, resource $context ] )
Attempts to rename oldname
to newname
, moving it between directories if necessary. If newname
exists, it will be overwritten.
Parameters:
oldname
Note:
The old name. The wrapper used in
oldname
must match the wrapper used innewname
.
newname
The new name.
context
Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Streams.
Returns:
Returns TRUE
on success or FALSE
on failure.
Changelog:
5.3.1
rename()
5.0.0
rename() some rename()
4.3.3
rename() chown() chmod()
Examples:
Example with rename()
<?php rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt"); ?>
See also:
copy() -
unlink() -
Please login to continue.