rename() function in php

高洛峰
Release: 2016-11-29 15:02:08
Original
3048 people have browsed it

php filesystem function, rename() function renames a file or directory. If successful, the function returns true. If it fails, false is returned.

Statement: rename(oldname, newname,context)

Parameter description

oldname is required, specifies the file or directory to be renamed.

newname is required, specifies the new name of the file or directory.

context is required and specifies the environment of the file handle. context is a set of options that can modify the behavior of the stream.

Note: Before PHP 4.3.3, rename() cannot rename across disk partitions in *nix-based systems File.

Note: The encapsulation protocol used in oldname must match the one used in newname.

Note: Support for context was added in php 5.0.0.

oldpath ----The original path of the file or directory, $newpath ----The new definition path, then rename($oldpath,$newpath) can complete the file / Directory moving operation, after my testing, both win32 and unix php4 versions support this function.

In addition, it seems that the win32 version of php4 has canceled the unlink() function, so you can also use the rename() function to complete it. Deletion operations, for example:

$path ---- file or directory path

$tmp ---- tmp directory (/tmp)

Use rename($path,$tmp) to move the file to the tmp directory.


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!