The use of rename functions in php

Source: Internet
Author: User
As we all know, the rename () function can rename files or directories. In fact, it can do a lot of things. If you are familiar with unix, you should know that the shell command mv is similar to win32, and can be renamed while moving. I found that the rename () function of php is equivalent to mv, which is not only SyntaxHighlighter

As we all know, the rename () function can rename files or directories. In fact, it can do a lot of things.

If you are familiar with unix, you should know that the shell command mv is similar to win32, and can be renamed while moving. I found that php's rename () function is equivalent to mv. it not only supports simple renaming, but also changes the path of the file and even the entire directory.

For example:
$ Oldpath ---- original path of the file or directory
$ Newpath ---- new definition path
Rename ($ oldpath, $ newpath) can be used to move the file/directory.

After my tests, both win32 and unix php4 support this function.

In addition, it seems that the win32 version of php4 has canceled the unlink () function. You can also use the rename () function to delete objects. for example:
$ Path ---- file or directory path
$ Tmp ---- tmp Directory (/tmp)
Use rename ($ path, $ tmp) to move the file 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.