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

A wonderful encyclopedia of rename() in PHP

autoload
autoloadOriginal
2021-03-24 17:55:352354browse

A wonderful encyclopedia of rename() in PHP

The rename() function of PHP is equivalent to the ## in unix #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.

    context is a set of options that can modify the behavior of the stream.

  • Return value: Returns

    TRUE on success, FALSE on 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:

<?php
rename("aPS","BPS");
?>
                b. www.txt is moved from

file1

to the file2 directory.

Both win32 and unix versions of php4 support this function. The win32 version of php4 has canceled the unlink() 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