rename

(PHP 4, PHP 5, PHP 7)
Renames a file or directory
bool rename ( string $oldname, string $newname [, resource $context ] )

Attempts to rename oldname to newname, moving it between directories if necessary. If newname exists, it will be overwritten.

Parameters:
oldname

Note:

The old name. The wrapper used in oldname must match the wrapper used in newname.

newname

The new name.

context

Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Streams.

Returns:

Returns TRUE on success or FALSE on failure.

Changelog:
5.3.1

rename()

5.0.0

rename() some rename()

4.3.3

rename() chown() chmod()

Examples:
Example with rename()
<?php
rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt");
?>

See also:

copy() -

unlink() -

move_uploaded_file() -

doc_php
2016-02-24 15:56:59
Comments
Leave a Comment

Please login to continue.