The command format is:
bool rename (string oldname, string newname [, resource context])
The following demonstrates the specific application of rename:
The file location is as shown in the figure:
Purpose: 1. Rename cache.txt to rename.txt;
2. Rename cache2.txt to cache3.txt
3. Rename the html directory to cache
4. Move the file directory to the html directory (Renaming can be achieved)
Code implementation (with errors):
Copy code The code is as follows:
php
$file = "html/cache.txt";
$rename = "html/rename.txt";
if(rename($file,$rename)){
echo "Rename Success";
}else{
echo "Rename failed";
}
rename("html/cache2","html/cache3.txt");
rename("html" ,"cache");
rename("file","html/files");
?>
Common error analysis:
Check the syntax and there is no problem; after checking, the file directory does not exist, causing an error. More files were compiled successfully
This error is small but fatal.
http://www.bkjia.com/PHPjc/323488.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323488.htmlTechArticleThe command format is: bool rename (string oldname, string newname [, resource context]) The following demonstrates the specific application of rename : The file location is as shown in the figure: Purpose: 1. Rename cache.txt to re...