Home>Article>Backend Development> A wonderful encyclopedia of rename() in PHP

A wonderful encyclopedia of rename() in PHP

autoload
autoload Original
2021-03-24 17:55:35 2327browse

A wonderful encyclopedia of rename() in PHP

Therename()function of PHPis equivalent to the ## inunix#shellCommandmv, it not only has a simple renaming function, but can also change the path of files or even entire directories.

1. Syntax:

rename(oldname,newname,context)

  • oldname is the file or directory to be renamed.


  • #newname is the new name of the file or directory.

  • context is the environment of the file handle.

    contextis a set of options that can modify the behavior of the stream.

  • Return value: Returns

    TRUEon success,FALSEon failure.

2. Purpose:

  • Mainly for files or directories Rename operation.

  • Secondly, rename() can be used to move files

##3. Example:

a. To rename the file:

b. www.txt is moved from

file1

to thefile2directory.

Both win32 and unix versions ofphp4support this function. The win32 version of php4 has canceled theunlink()function.

Recommended: "php video tutorial" "php tutorial"

The above is the detailed content of A wonderful encyclopedia of rename() in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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