The command format is:
BOOL Rename (string oldname, string newname [, resource context])
The following shows the specific application of rename:
File location
Objective: 1. Rename Cache.txt to Rename.txt;
2. Rename 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 error):
Copy CodeThe code is as follows:
$file = "Html/cache.txt";
$rename = "Html/rename.txt";
if (rename ($file, $rename)) {
echo "renamed successfully";
}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 an error. More files compiled successfully
This is a small mistake, it's deadly.
http://www.bkjia.com/PHPjc/323488.html www.bkjia.com true http://www.bkjia.com/PHPjc/323488.html techarticle The command format is: BOOL Rename (string oldname, string newname [, resource context]) The following shows the specific application of rename: File location Purpose: 1. Rename Cache.txt to re ...