Rename change file, folder name _php tutorial

Source: Internet
Author: User
The rename () command can be used to rename the file folder, and can also be used to move files and folders, in the following format:

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):
$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 error is small, deadly ............... ........

http://www.bkjia.com/PHPjc/478824.html www.bkjia.com true http://www.bkjia.com/PHPjc/478824.html techarticle the rename () command can be used to rename the file folder, and can also be used to move files and folders, with the following command format: 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.