The rename() function renames a file or directory. The function returns TRUE on success or FALSE on failure.
Syntax
rename(old_filename, new_filename, context)
Parameters
old_filename − The old name of the file or directory.
new_filename − The new name of the file or directory.
context − Specify the behaviour of the stream.
Return
The rename() function returns TRUE on success or FALSE on failure.
Example
<?php rename("one.txt","two.txt"); ?>
Output
TRUE
Let us see another example.
Example
<?php rename("D:\new\tutorials\java.docx","D:\new\tutorials\programming\java.docx"); ?>
Output
TRUE