Dark Launch

PHP mkdir recursive with parents

Recursively create directories in PHP with mkdir().

$ mkdir --parents
PHP
function mkdir_p($directory, $mode=0700) {
    $recursive = TRUE;
    return @mkdir($directory, $mode, $recursive);
}

Note the @ is to ignore any existing folder.

Comments


  1. what about:
    mkdir($_SERVER['DOCUMENT_ROOT'] . _PATH . '/' . $directory, 777, true);