The example in this article describes the method of creating a multi-level directory in php. Share it with everyone for your reference. The specific implementation method is as follows:
<?php /* 写出一个能创建多级目录的PHP函数 */ function createdirlist($path,$mode){ if (is_dir($path)){ //判断目录存在否,存在不创建 echo "目录'" . $path . "'已经存在"; //已经存在则输入路径 }else{ //不存在则创建目录 $re=mkdir($path,$mode,true); //第三个参数为true即可以创建多极目录 if ($re){ echo "目录创建成功";//目录创建成功 }else{ echo "目录创建失败"; } } } $path="/a/x/cc/cd"; //要创建的目录 $mode=0755; //创建目录的模式,即权限. createdirlist($path,$mode);//测试
I hope this article will be helpful to everyone’s PHP programming design.