note 123657 added to function.file-put-contents
| From: | maksam07 at gmail dot com | Date: | Tue, 05 Mar 2019 10:47:13 +0000 |
| Subject: | note 123657 added to function.file-put-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-210322@lists.php.net to get a copy of this message | ||
A slightly simplified version of the method: http://php.net/manual/ru/function.file-put-contents.php#84180
<?php
function file_force_contents( $fullPath, $contents, $flags = 0 ){
$parts = explode( '/', $fullPath );
array_pop( $parts );
$dir = implode( '/', $parts );
if( !is_dir( $dir ) )
mkdir( $dir, 0777, true );
file_put_contents( $fullPath, $contents, $flags );
}
file_force_contents( ROOT.'/newpath/file.txt', 'message', LOCK_EX );
?>
----
Server IP: 208.43.231.9
Probable Submitter: 185.85.3.142 (proxied: 188.190.215.21)
----
Manual Page -- http://php.net/manual/en/function.file-put-contents.php
Edit -- https://master.php.net/note/edit/123657
Del: integrated -- https://master.php.net/note/delete/123657/integrated
Del: useless -- https://master.php.net/note/delete/123657/useless
Del: bad code -- https://master.php.net/note/delete/123657/bad+code
Del: spam -- https://master.php.net/note/delete/123657/spam
Del: non-english -- https://master.php.net/note/delete/123657/non-english
Del: in docs -- https://master.php.net/note/delete/123657/in+docs
Del: other reasons-- https://master.php.net/note/delete/123657
Reject -- https://master.php.net/note/reject/123657
Search -- https://master.php.net/manage/user-notes.php