PHP rename() Function

The rename() function renames a file or directory.This function returns TRUE on success, or FALSE on failure.

bool rename ( string $oldname , string $newname [, resource $context ] )

Attempts to rename oldname to newname, moving it between directories if necessary. If renaming a file and newname exists, it will be overwritten. If renaming a directory and newname exists, this function will emit a warning.

Example -

ParameterDescription
oldnameSpecifies the file or directory to be renamed
newnameSpecifies the new name of the file or directory
contextSpecifies the context of the file handle. Context is a set of options that can modify the behavior of a stream