note 82805 added to function.fopen
| From: | webmaster at myeshop dot fr | Date: | Sat, 26 Apr 2008 14:40:15 +0000 |
| Subject: | note 82805 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138805@lists.php.net to get a copy of this message | ||
Also a small function useful for backup for example. It's a mixed between the fopen() and the
mkdir() functions.
This function opens a file but also make the path recursively where the file is contained. This is
helpful for ending to finish with "No such file or directory in" errors
function fopen_recursive($path, $mode, $chmod=0755){
preg_match('
^(.+)/([a-zA-Z0-9]+\.[a-z]+)$i', $path, $matches);
$directory = $matches[1];
$file = $matches[2];
if (!is_dir($directory)){
if (!mkdir($directory, $chmod, 1)){
return FALSE;
}
}
return fopen ($path, $mode);
}
----
Server IP: 213.246.42.8
Probable Submitter: 84.98.216.13
----
Manual Page -- http://www.php.net/manual/en/function.fopen.php
Edit -- https://master.php.net/note/edit/82805
Del: integrated -- https://master.php.net/note/delete/82805/integrated
Del: useless -- https://master.php.net/note/delete/82805/useless
Del: bad code -- https://master.php.net/note/delete/82805/bad+code
Del: spam -- https://master.php.net/note/delete/82805/spam
Del: non-english -- https://master.php.net/note/delete/82805/non-english
Del: in docs -- https://master.php.net/note/delete/82805/in+docs
Del: other reasons-- https://master.php.net/note/delete/82805
Reject -- https://master.php.net/note/reject/82805
Search -- https://master.php.net/manage/user-notes.php