Home >Backend Development >PHP Tutorial >How to use the rename() function in php
This article mainly introduces the usage of rename() function in php. It analyzes the meaning of parameters in the rename() function and the specific usage method in more detail. It has certain reference value and needs Friends can refer to
This article analyzes the usage of the rename() function in PHP with examples. Share it with everyone for your reference. The details are as follows: php Statement: rename(oldname,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.The code is as follows:
<?php rename("images","pictures"); ?>oldpath ---- the original path of the file or directory, $newpath ---- the new defined path, then rename($oldpath,$newpath) can be completed 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, so you can also use rename cleverly () function to complete the
delete
operation, for example:$path ---- file or directory path
$tmp ---- tmp directory (/tmp )Use rename($path,$tmp) to move the file to the tmp directory.The above is the detailed content of How to use the rename() function in php. For more information, please follow other related articles on the PHP Chinese website!