UCE Docs / file_rename

Signature

bool file_rename(String from, String to)

Parameters

from : source path
to : destination path
return value : true on success

Renames or moves a file. After a successful rename the source path no longer exists. Use it for atomic publish patterns: write a temp file, then rename it into place.

Example

file_put_contents("/tmp/doc-rename-a.txt", "moved");
file_rename("/tmp/doc-rename-a.txt", "/tmp/doc-rename-b.txt");
print(file_get_contents("/tmp/doc-rename-b.txt"), " / source ", file_exists("/tmp/doc-rename-a.txt") ? "exists" : "gone", "\n");
Output
moved / source gone