The use of the rename () function in php

Source: Internet
Author: User
As we all know, the rename () function can rename files or directories. It can also do many things. Friends familiar with unix should know the shell command mv, which is equivalent to win32 movement, and can be renamed at the same time. everyone knows that rename () the function can rename a file or directory. It can also do many things.

Friends familiar with unix should know the shell command mv, which is equivalent to win32 movement and can be renamed while moving. I found that php's rename () function is equivalent to mv. it not only has the simple rename function, but also can change the path of files or even all directories.

For example:

$ Oldpath ---- original path of the file or directory
$ Newpath ---- new definition path

Then rename ($ oldpath, $ newpath) can complete the control of file/directory movement

The php4 versions of win32 and unix 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 complete the deletion control. 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.