note 94952 added to function.file-put-contents
| From: | Anonymous at osu1 dot php dot net | Date: | Fri, 04 Dec 2009 01:30:45 +0000 |
| Subject: | note 94952 added to function.file-put-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163562@lists.php.net to get a copy of this message | ||
Create dir path if trying to write to a directory that does not exist yet
function forceContent($filePath, $content, $dirMode = 0777)
{
// Get path information
$pathInfo = pathinfo($filePath);
// Check if path exists
if(!file_exists($pathInfo['dirname'])) {
$result = mkdir($pathInfo['dirname'], 0777, true);
if($result == false) {
return false;
}
}
// Create file
return file_put_contents($filePath, $content);
}
----
Server IP: 212.63.193.10
Probable Submitter: 85.226.244.18
----
Manual Page -- http://www.php.net/manual/en/function.file-put-contents.php
Edit -- https://master.php.net/note/edit/94952
Del: integrated -- https://master.php.net/note/delete/94952/integrated
Del: useless -- https://master.php.net/note/delete/94952/useless
Del: bad code -- https://master.php.net/note/delete/94952/bad+code
Del: spam -- https://master.php.net/note/delete/94952/spam
Del: non-english -- https://master.php.net/note/delete/94952/non-english
Del: in docs -- https://master.php.net/note/delete/94952/in+docs
Del: other reasons-- https://master.php.net/note/delete/94952
Reject -- https://master.php.net/note/reject/94952
Search -- https://master.php.net/manage/user-notes.php