How to create and delete php folder,
The example in this article describes how to create and delete php folders. Share it with everyone for your reference. The details are as follows:
1. Create a folder
Copy code The code is as follows:
//Creation of folder
$file_path = "d:/fold/";
if(!file_exists($file_path)){
mkdir($file_path);
echo "Folder created successfully";
}else{
echo "The folder already exists";
}
?>
2. Create folders, recursively
Copy code The code is as follows:
//Create folders, multi-layer nested folders (recursive)
$file_path = "d:/fold/aaa/bbb/";
if(!file_exists($file_path)){
mkdir($file_path,0777,true);//0777 indicates folder permissions, which is invalid by default in Windows, but because the third parameter is used here, it must be filled in; true/false indicates whether the folder can be created recursively
echo "Folder created successfully";
}else{
echo "The folder already exists";
}
?>
3. Delete the folder
Copy code The code is as follows:
//Delete folder
$file_path = "d:/fold/aaa/bbb/";
if(is_dir($file_path)){//First determine whether it is a folder
if(rmdir($file_path)){//Determine whether the deletion can be successful
echo "Folder deleted successfully";
}else{
echo "Cannot delete folder";//If the folder is not empty, it cannot be deleted
}
}else{
echo "The folder does not exist";
}
?>
I hope this article will be helpful to everyone’s PHP programming design.
http://www.bkjia.com/PHPjc/947216.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/947216.htmlTechArticleHow to create and delete php folders. This article describes the creation and deletion methods of php folders. Share it with everyone for your reference. The details are as follows: 1. Create a folder and copy the code...