Rename a directory or file.
| <?php rename(“images”,“pictures”); rename(“/test/file1.txt”,“/home/docs/my_file.txt”); ?> |
The rename() function changes the name of a file or directory.
| rename(old, new, context) |
|
Parameter |
Description |
|
old |
Required. Specifies the file or directory to rename. |
|
new |
Required. Specifies the new name for the file or directory. |
|
context |
Optional. Specifies the context for the file handle, which is a set of options that can alter the behavior of the stream. |
|
Return Value: |
Returns TRUE on success, FALSE on failure. |
|
PHP Version: |
4.0+ |
|
PHP Changelog: |
PHP 5.3.1 introduced support for renaming files across drives on Windows. PHP 5.0 added the ability to use |