The rename () command can be used to rename a file folder, and the command format for moving files and folders is as follows:
Bool rename (string oldname, string newname [, resource context])
The following demonstrates the specific rename application:
File location
Purpose: 1.change cache.txt to rename.txt;
2.change cache2.txtname to cache3.txt
3. rename the html directory to cache
4. transfer the file directory to the html Directory (renamed)
Code implementation (with errors ):
The code is as follows:
$ File = "html/cache.txt ";
$ Rename = "html/rename.txt ";
If (rename ($ file, $ rename )){
Echo "renamed ";
} Else {
Echo "renaming failed ";
}
Rename ("html/cache2", "html/cache3.txt ");
Rename ("html", "cache ");
Rename ("file", "html/files ");
?>
Common Error analysis:
Check the syntax. the file directory does not exist, causing an error. Files compiled successfully
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.