Rename function usage analysis in PHP, phprename function Usage _php Tutorial

Source: Internet
Author: User

Rename function usage analysis in PHP, Phprename function usage


This paper analyzes the usage of rename () function in PHP. Share to everyone for your reference. Specific as follows:

The PHP filesystem function, the rename () function renames the file or directory, and if successful, the function returns True. If it fails, it returns false.

Statement: rename (oldname,newname,context)

Parameters Describe
Oldname Required to specify the file or directory to be renamed.
NewName Required, specify a new name for the file or directory
Context Required, specifies the context of the file handle, which is a set of options for modifying the behavior of the stream

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.
Copy the Code code as follows: <?php
Rename ("Images", "pictures");
?>

OldPath----The original path of the file or directory, $newpath----The new defined path, then rename ($oldpath, $newpath) can complete the file/directory move operation, after my test, This feature is supported in the PHP4 versions of Win32 and UNIX.

In addition, 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).

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/912280.html www.bkjia.com true http://www.bkjia.com/PHPjc/912280.html techarticle Rename function usage analysis in PHP, Phprename function Usage This paper analyzes the usage of rename () function in PHP. Share to everyone for your reference. Specific as follows: PHP filesystem function, Rena ...

  • Related Article

    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.