English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP Filesystem Reference Manual
The mkdir() function can create a directory, and this function returns true when successful and false when failed.
bool mkdir ( string $pathname[, int $mode = 0777 [, bool $recursive = FALSE[, resource $context]]])
This function attempts to create the directory specified by pathname.
Using mkdir to create a directory
<?php mkdir("/PhpProject/testing"); echo "Directory creation successful!!!"; ?>
Output result
Directory creation successful!!!
Create the root directory and subdirectories at the same time, multiple directories
<?php $structure = "/PhpProject/test1/test2/test3"; if(!mkdir($structure, 0777, true)) { echo "Unable to create folder..."; } else { echo "All directories created successfully!!!"; } ?>
Output result
All directories created successfully!!!