PHP Functions: The Magical function of rename () in PHP

Source: Internet
Author: User
As you all know, the rename () function can rename a file or directory. In fact, it can do a lot of things.

A friend familiar with Unix should know the shell command MV, which is quite moving with Win32, and can be renamed while moving. I found that PHP's rename () function is the equivalent of MV, which is not just a simple renaming function, it can also change the path of the file or even the entire directory.

For example:

OldPath----file or directory original path
NewPath----a new defined path

Then rename (Oldpath,newpath) can complete the file/directory move operation

This feature is supported in the PHP4 versions of Win32 and UNIX.

Also, as if PhP4 's Win32 version cancels the unlink () function. You can also use the rename () function to complete the removal operation, for example:

Path----file or directory paths
TMP----TMP directory (/tmp)

Use rename (path,tmp) to move the files to the TMP directory.

  • 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.