Home > Backend Development > PHP Tutorial > The wonderful use of the rename function in php_PHP tutorial

The wonderful use of the rename function in php_PHP tutorial

WBOY
Release: 2016-07-13 17:26:01
Original
830 people have browsed it

As we all know, the rename() function can rename files or directories. In fact, it can do a lot of things.

Friends who are familiar with Unix should know the shell command mv, which is equivalent to win32 movement, and can be renamed while moving. I found that php's rename() function is equivalent to mv. It not only has a simple renaming function, but can also change the path of files or even entire directories.

For example:
$oldpath ---- original path of file or directory
$newpath ---- new defined 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. Then you can also use the rename() function to complete the deletion operation, for example:
$path ---- file or directory path
$tmp ---- tmp directory (/tmp)
Use rename ($path,$tmp) Move the file to the tmp directory.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532007.htmlTechArticleAs we all know, the rename() function can rename files or directories. In fact, it can do a lot of things. Friends who are familiar with Unix should know the shell command mv, which is quite similar to w...
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