首先需要检查目录是否存在:file_exists('path_to_directory')
然后使用mkdir(path_to_directory)
来创建目录。
mkdir( string $pathname [, int $mode = 0777 [, bool $recursive = FALSE [, resource $context ]]] ) : bool
更多关于mkdir()的信息请点击此处
完整代码如下:
$structure = './depth1/depth2/depth3/';
if (!file_exists($structure)) {
mkdir($structure);
}