note 91363 added to function.fopen
| From: | gmdebby at gmail dot com | Date: | Mon, 08 Jun 2009 13:49:20 +0000 |
| Subject: | note 91363 added to function.fopen | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156473@lists.php.net to get a copy of this message | ||
I was wondering why was added the "x" mode, it works only if the file do not exists, will
create it and open it in read only, it's useless !!
But I found something I could do with that.
Here is a little mk_file function.
<?php
function mk_file($filename) {
if(!is_file($filename)) {
fclose(fopen($filename,"x")); //create the file and close it
return true;
} else return false; //file already exists
}
?>
You can improve it, add chmod support etc...
----
Server IP: 89.31.146.176
Probable Submitter: 90.3.255.169
----
Manual Page -- http://www.php.net/manual/en/function.fopen.php
Edit -- https://master.php.net/note/edit/91363
Del: integrated -- https://master.php.net/note/delete/91363/integrated
Del: useless -- https://master.php.net/note/delete/91363/useless
Del: bad code -- https://master.php.net/note/delete/91363/bad+code
Del: spam -- https://master.php.net/note/delete/91363/spam
Del: non-english -- https://master.php.net/note/delete/91363/non-english
Del: in docs -- https://master.php.net/note/delete/91363/in+docs
Del: other reasons-- https://master.php.net/note/delete/91363
Reject -- https://master.php.net/note/reject/91363
Search -- https://master.php.net/manage/user-notes.php