note 53337 deleted from function.mkdir by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 18:12:47 +0000 |
| Subject: | note 53337 deleted from function.mkdir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133260@lists.php.net to get a copy of this message | ||
Note Submitter: David Pullen
----
A simple recursive mkdir function:
<?php
function RecursiveMkdir($path)
{
// This function creates the specified directory using mkdir(). Note
// that the recursive feature on mkdir() is broken with PHP 5.0.4 for
// Windows, so I have to do the recursion myself.
if (!file_exists($path))
{
// The directory doesn't exist. Recurse, passing in the parent
// directory so that it gets created.
RecursiveMkdir(dirname($path));
mkdir($path, 0777);
}
}
if (!file_exists("/path/to/my/file"))
{
// Call the recursive mkdir function since the "recursive" feature
// built in to mkdir() is broken.
RecursiveMkdir("/path/to/my/file");
}
?>