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

A wonderful encyclopedia of rename() in PHP

autoload
Release: 2023-04-09 20:28:02
Original
2495 people have browsed it

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)
Copy after login

  • 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");
?>
Copy after login
                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!

Related labels:
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