1// Create a directory with the permission level (optional)
2<?php
3mkdir("/path/to/my/dir", 0700);
4?>
1<?php
2// Create a directory recursively (make sure to sanitize if taken from input as always!)
3mkdir("/path/to/my/dir", 0777, true);
1
2<?php
3// Desired directory structure
4$structure = './depth1/depth2/depth3/';
5
6// To create the nested structure, the $recursive parameter
7// to mkdir() must be specified.
8
9if (!mkdir($structure, 0777, true)) {
10 die('Failed to create directories...');
11}
12
13// ...
14?>
15
16