note 83476 added to function.fwrite

From: Date: Tue, 27 May 2008 18:11:26 +0000
Subject: note 83476 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-139873@lists.php.net to get a copy of this message
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"; //} ?> ---- Server IP: 64.71.164.2 Probable Submitter: 69.120.118.155 ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- https://master.php.net/note/edit/83476 Del: integrated -- https://master.php.net/note/delete/83476/integrated Del: useless -- https://master.php.net/note/delete/83476/useless Del: bad code -- https://master.php.net/note/delete/83476/bad+code Del: spam -- https://master.php.net/note/delete/83476/spam Del: non-english -- https://master.php.net/note/delete/83476/non-english Del: in docs -- https://master.php.net/note/delete/83476/in+docs Del: other reasons-- https://master.php.net/note/delete/83476 Reject -- https://master.php.net/note/reject/83476 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139873) next »