PHP rename() Function

PHP rewind() Function
PHP realpath_cache_size() Function

In this article, you will learn how to change the name of a file or folder in PHP. The rename() function in PHP renames a file or directory.

what is the syntax of the RENAME function in php?

rename(old, new, context)
ParameterDescription
oldRequired. Specifies the file or directory to be renamed
newRequired. Specifies the new name for the file or directory
contextOptional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream
PHP rename() method

examples of the RENAME function

Example 1. In this example, we rename a directory + a file.

<?php
rename("images","pictures");
rename("/test/file1.txt","/home/docs/my_file.txt");
?>
PHP rewind() Function
PHP realpath_cache_size() Function
en English
X
Scroll to Top