PHP rename() Function
❮ PHP Filesystem ReferenceExample
Rename a directory + a file:
<?php
rename("images","pictures");
rename("/test/file1.txt","/home/docs/my_file.txt");
?>
Definition and Usage
The rename() function renames a file or directory.
Syntax
rename(old, new, context)
Parameter Values
Parameter | Description |
---|---|
old | Required. Specifies the file or directory to be renamed |
new | Required. Specifies the new name for the file or directory |
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream |
Technical Details
Return Value: | TRUE on success, FALSE on failure |
---|---|
PHP Version: | 4.0+ |
PHP Changelog: | PHP 5.3.1: Allow renaming files across drives in Windows. PHP 5.0: Can be used with some URL wrappers. |
❮ PHP Filesystem Reference