RenameChange file and folder names_PHP tutorial

WBOY
Release: 2016-07-13 17:43:25
Original
881 people have browsed it

The rename() command can rename files and folders, and can also move files and folders. The command format is:

bool rename ( string oldname, string newname [, resource context] )

The following demonstrates the specific application of rename:

The file location is as shown:



Purpose: 1. Rename cache.txt to rename.txt;RenameChange file and folder names_PHP tutorial

2. Rename cache2.txt to cache3.txt

3. Rename the html directory to cache

4. Move the file directory to the html directory (rename can be achieved)


Code implementation (with errors):
$file = "html/cache.txt";
$rename = " html/rename.txt";
if(rename($file,$rename)){
echo "Name change successful";
}else{
echo "Name change failed";
}
rename("html/cache2","html/cache3.txt");
rename("html","cache");
rename("file","html/files");
?>

Common error analysis:
RenameChange file and folder names_PHP tutorial

Check the syntax and there is no problem; after checking, the file directory does not exist, causing an error. More files were compiled successfully

This mistake is small but fatal………………

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478824.htmlTechArticleThe rename() command can rename files and folders, and can also move files and folders , the command format is: bool rename ( string oldname, string newna...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!