PHP rename () function _php Tutorial

Source: Internet
Author: User

PHP Tutorial Rename () function

PHP filesystem functions

Definition and usage

The rename () function renames the file or directory.

If successful, the function returns True. If it fails, it returns false.

Grammar

Rename (Oldname,newname,context)
Parameters Description
Oldname Necessary. Specifies the file or directory to be renamed.
NewName Necessary. Specify a new name for the file or directory.
Context Necessary. Specifies the environment for file handles. Context is a set of options for modifying the behavior of a stream.

Hints and Notes

Note: rename () cannot rename files across disk partitions in a *nix-based system until PHP 4.3.3.

Note: The encapsulation protocols used in Oldname must match those used in newname.

Note: support for the context is added by PHP 5.0.0.

Example

 
  
OldPath----file or directory original path
$newpath----a new defined path
Then rename ($oldpath, $newpath) will be able to complete the operation of File/directory move
Through my tests, Win32 and UNIX versions of PHP4 support this feature.
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 path
$TMP----tmp directory (/tmp)
Move the file to the TMP directory with rename ($path, $tmp).

http://www.bkjia.com/PHPjc/445427.html www.bkjia.com true http://www.bkjia.com/PHPjc/445427.html techarticle PHP Tutorial rename () function PHP filesystem function definition and usage rename () function to rename a file or directory. If successful, the function returns True. If it fails, it returns false. Grammar ...

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