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<?php
2// Desired directory structure
3$structure = './depth1/depth2/depth3/';
4
5// To create the nested structure, the $recursive parameter
6// to mkdir() must be specified.
7
8if (!mkdir($structure, 0777, true)) {
9 die('Failed to create directories...');
10}
11