PHP rename() Function
❮ PHP Filesystem ReferenceExample
Rename a directory and 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(from, to, context)
Parameter Values
| Parameter | Description |
|---|---|
| from | Required. Specifies the file/directory to be renamed |
| to | Required. Specifies the new name for the file/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 Filesystem Reference