Re: Problem with the fwrite function (not as simple as it sounds though)

From: Date: Sun, 20 Nov 2005 00:58:49 +0000
Subject: Re: Problem with the fwrite function (not as simple as it sounds though)
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-226138@lists.php.net to get a copy of this message
Hello again, some extra info on my case: the fwrite is completely fine, when fopen is in 'a' mode! Thus leading to a temporary workaround like this: $file = "/wwwroot/file" $countt = explode(".", fread(fopen($file,"r"), filesize($file))); $count=$countt[1]; $count++; $handle=fopen($file,"a"); ftruncate($handle, 1); fwrite($handle,$file); fclose($handle); Now having a file with content in the form: .15 makes it possible to use the above as a workaround.. but still I need to find out what's the problem here. The counter isn't exactly the only thing I use fwrite for.. The clue I got is, non-empty files are ok to be written in (appended), empty on the other hand, are totaly uncool for that. So using a ftruncate($handle,0); is just as I'd use fopen($file,"w"); (gives the same result). -- Best wishes Still hoping for Your help Łukasz Hejnak

« previous php.general (#226138) next »