PHP mkdir()函数
mkdir()函数可以创建一个目录,当成功时该函数返回true,当失败时返回false。
语法
bool mkdir ( string pathname [, intmode = 0777 [, bool recursive = FALSE [, resourcecontext ]]] )
该函数可以尝试根据路径名创建目录。
示例1
<?php
mkdir("/PhpProject/testing");
echo "Directory created successfully!!!";
?>
输出
Directory created successfully!!!
语法
示例2
<?php
structure = "/PhpProject/test1/test2/test3";
if(!mkdir(structure, 0777, true)) {
echo "Failed to create folders...";
} else {
echo "Nested structure created successfully!!!";
}
?>
输出
Nested structure created successfully!!!