Re: fwrite not writing

From: Date: Mon, 16 Apr 2001 06:10:09 +0000
Subject: Re: fwrite not writing
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-48708@lists.php.net to get a copy of this message
What is this: !filesize($filepath) Add this above your if loop: $filesize = filesize($filepath); echo $filesize; That might be causing your loop not to execute...if not, I'm not sure what's wrong. -- Plutarck Should be working on something... ...but forgot what it was. "CC Zona" <cczona@nospam.invalid> wrote in message news:9bdv8u$2la$1@toye.p.sourceforge.net... > This function suddenly stopped working, and I just can't seem to figure out > why. The only change made recently is that now the value of $force at > calltime is sometimes true instead of being undefined or null. > > build_file("file_content","/path/to/file.inc","w",TRUE); > > function build_file($func_name,$filepath,$mode="w",$force=FALSE) > { > if($force or !file_exists($filepath) or !filesize($filepath)) //echo > filesize($filepath) shows '0' > { > $content=$func_name(); //echo $content shows it's all there > $fp=fopen($filepath,$mode); > fwrite($fp,$content); > rewind($fp); #temp test > $read_back=fread($fp,100000); #temp test > echo "<p>file content:</p>\n $read_back"; #temp test, displays nothing > fclose($fp); > } > } > > I've tried putting echoes and "or die('Error on __LINE__')" on every > line, > checked all the variable values, and found no answers from that. > Everything shows exactly as it should be except that the content that > echoes out so nicely *doesn't ever get written to the file*. The function > runs to the end without error and the file's modification date is even > updated. But the file remains empty. I'm probably missing something > ridiculously obvious, but would someone please be kind enough to point out > what it is? Thank you!! > > -- > CC > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#48708) next »