Home > Backend Development > PHP Problem > What is the function in php to modify the file name?

What is the function in php to modify the file name?

藏色散人
Release: 2023-03-10 06:50:01
Original
2485 people have browsed it

php's function to modify the file name is rename(). The function of this function is to rename the file or directory. Its usage syntax is "rename(oldname, newname, context)". The parameter oldname specifies the name to be renamed. file or directory, and the parameter newname specifies the new name of the file.

What is the function in php to modify the file name?

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

The rename() function renames files or directories.

If successful, the function returns true. On failure, returns false.

Syntax

rename(oldname,newname,context)
Copy after login

Parameters

oldname required. Specifies the file or directory to be renamed.

newname Required. Specifies the new name of the file or directory.

context Optional. Specifies the environment for a file handle. context is a set of options that modify the behavior of the stream.

Tips and Notes

Note: Prior to PHP 4.3.3, rename() could not rename files across disk partitions on *nix-based systems.

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.

Example

<?php
rename("images","pictures");
?>
Copy after login

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the function in php to modify the file name?. For more information, please follow other related articles on the PHP Chinese website!

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