The command format is:
BOOL Rename (string oldname, string newname [, resource context])
Below is a demonstration of the specific application of rename:
File location as shown:
Objective: 1. renamed Cache.txt as Rename.txt;
2. Rename the cache2.txt to Cache3.txt
3. Rename the HTML directory to cache
4. Transfer the file directory to the HTML directory (can be renamed)
Code implementation (with errors):
Copy Code code as follows:
<?php
$file = "Html/cache.txt";
$rename = "Html/rename.txt";
if (rename ($file, $rename)) {
echo "renamed success";
}else{
echo "Renaming failed";
}
Rename ("Html/cache2", "html/cache3.txt");
Rename ("HTML", "cache");
Rename ("File", "Html/files");
?>
Common Error Analysis:
Check the syntax, no problem, the file directory does not exist, resulting in errors. More files compiled successfully
This is a small mistake, fatal.