Home  >  Article  >  Backend Development  >  php folder operations

php folder operations

WBOY
WBOYOriginal
2016-08-08 09:24:591597browse

Create Folder:

<?php
//文件夹的创建
$newDir = "c:/php创建的文件夹/文件夹1/文件夹2";

if(!is_dir($newDir)){
	if(!mkdir($newDir,0777,true)){
		echo "创建文件夹失败";
	}else{
		echo "创建文件夹成功";
	}
}else{
	echo "该文件夹已经存在";
}
?>

Delete Folder:

Note: Only empty folders can be deleted

<?php

$rmDir = "c:/php创建的文件夹/文件夹1/文件夹2";

if(is_dir($rmDir)){
	if(!rmdir($rmDir)){
		echo "删除文件失败";
	}else{
		echo "删除文件夹成功";
	}
}else{
	echo "不存在该文件夹";
}
?>

The above introduces the php folder operation, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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