Create a directory in php
The mkdir() php function can be used to create a directory provided that the necessary file permissions exist.
Example on mkdir():
<?php if (file_exists("/temp/test")) { print("Test Directory already exists.\n"); } else { mkdir("/temp/test"); print("Test Directory created.\n"); } ?>
Output – first execution
Test Directory created.
If you run this script again, it will print:
Test Directory already exists.
Filed Under: PHP File Handling