note 40085 added to function.fwrite

From: Date: Sat, 21 Feb 2004 04:19:56 +0000
Subject: note 40085 added to function.fwrite
Groups: php.notes 
Request: Send a blank email to php-notes+get-65472@lists.php.net to get a copy of this message
This is correction: This a correction for the second example , because $filename is not a variable, so the right way is this (i test it): <?php $file = "example.txt"; if (!$handle = fopen($file, 'a')) { print "Cannot open file ($file)"; exit; } $somecontent = "Hello"; if(is_writable($file)){ if (!fwrite($handle, $somecontent)) { print "Cannot write to file ($file)"; exit; } } else { chmod ($file , 0777) or die ("I found out you couldn't write to the file so I tried to chmod it but it didn't work"); echo "Please refresh the page"; } ?> so this script will write it in the example.txt, the word Hello. C32/. ---- Manual Page -- http://www.php.net/manual/en/function.fwrite.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40085 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40085&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40085&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65472) next »