note 119828 deleted from function.fopen by cmb

From: Date: Fri, 09 Sep 2016 22:32:16 +0000
Subject: note 119828 deleted from function.fopen by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-206546@lists.php.net to get a copy of this message
Note Submitter: arnold at nijboer dot it ---- if not provided with a handle, fopen will close automatic! so instead of <?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 } ?> as gmdebby suggested. you can do <?php if(fopen($filename,"x+")) { file_put_content($filename,$str); } ?>

« previous php.notes (#206546) next »