PhpRename change file and folder name_php tutorial

Source: Internet
Author: User
PhpRename: change the file and folder name. The command format is: boolrename (stringoldname, stringnewname [, resourcecontext]). The following shows the specific application of rename: file location objective: 1. rename cache.txt to re. the command format is:
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

This error is fatal.

Using bool rename (string oldname, string newname [, resource context]) below demonstrates the specific application of rename: Object location objective: 1. rename cache.txt to re...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.