note 83476 deleted from function.fwrite by sobak

From: Date: Thu, 01 Dec 2016 17:58:17 +0000
Subject: note 83476 deleted from function.fwrite by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207912@lists.php.net to get a copy of this message
Note Submitter: michael at newbcity dot com ---- For my fellow newbies, if you test the sample script and want to have the .txt file created for you, you need to comment out the is_writable stuff, like this: <?php $filename = 'test.txt'; $somecontent = "Add this to the file\n"; // Let's make sure the file exists and is writable first. //if (is_writable($filename)) { // In our example we're opening $filename in append mode. // The file pointer is at the bottom of the file hence // that's where $somecontent will go when we fwrite() it. if (!$handle = fopen($filename, 'a')) { echo "Cannot open file ($filename)"; exit; } // Write $somecontent to our opened file. if (fwrite($handle, $somecontent) === FALSE) { echo "Cannot write to file ($filename)"; exit; } echo "Success, wrote ($somecontent) to file ($filename)"; fclose($handle); //} else { //echo "The file $filename is not writable"; //} ?>

« previous php.notes (#207912) next »