PHP » I/O » rename()

Syntax:
bool rename(string old_name, string new_name)
old_name
File that is to be renamed.
new_name
The new name for the file.

Renames a file.

rename() renames a file. TRUE is returned on success. If an error occurs, FALSE is returned.

Examples

Code:
<?php

if (rename("log2.txt", "backup/logbackup.txt")) {
   print "File renamed";
}

?>
Output:
File renamed
Explanation:

This code renames a file and moves it to the backup directory.

See Also: