Rename file and folder name_php tutorial-PHP Tutorial

Source: Internet
Author: User
Rename: change the file and folder name. The rename () command can be used to rename a file folder and move files and folders. the command format is boolrename (stringoldname, stringnewna rename () the command can be used to rename a file folder and move files and folders. the command format is as follows:

Bool rename (stringOldname,StringNewname [, 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 ):
$ 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 too small and fatal ..............................

The http://www.bkjia.com/PHPjc/478824.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/478824.htmlTechArticlerename () command can realize the renaming operation of the file folder, but also can realize the movement operation of the file and folder, the command format is: bool rename (string oldname, string newna...

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.