<?PHP mkdir("tp/");//create directory tp/ in current directory by default mkdir("./tp/");//create directory tp/ in current directory if (!file_exists("../tp/")) mkdir("../tp/");//create directory tp/ in upper directory if not exists ?>
By default the new created directory can be accessed and modified by anybody. To create a user read only directory.
<?PHP mkdir("tp/",0400); //read only ?>
If the recursive option is true, nested directories can be created.
<?PHP mkdir("1/2/3/",0400,true); //create 1/2/3/ under current directory ?>
<?PHP if (is_empty("tp/")) rmdir("tp/"); function is_empty($dir) { $rad = opendir($dir); while (($file = readdir($rad)) !== false) { if ($file != "." && $file != "..") { closedir($rad); return FALSE; } } closedir($rad); return TRUE; } ?>