RE: [PHP] fwrite: Want to write PHP generated output to file

From: Date: Thu, 09 Nov 2000 04:11:12 +0000
Subject: RE: [PHP] fwrite: Want to write PHP generated output to file
Groups: php.general 
Request: Send a blank email to php-general+get-24423@lists.php.net to get a copy of this message
> function make_page(){ > $web_page=make_page2(); You seem to assume here that $web_page now contains the result of the make_page2() function, but it doesn't. > print "hello world"; > touch("public_html/home.html"); > $file="public_html/home.html"; > $fp = fopen($file,"w+"); > fwrite($fp, make_page2()); ^^^^^^^^^^^^ Why execute it twice, use $web_page. > fclose($fp); > } > function make_page2(){ > global $colors,$heading etc; > <snip> > usual php/html output here using form variables > > </snip> > print "</center>\n"; > print "</body>\n"; > print "</html>\n"; > } This function should store its output up into a single big string and then return it: function make_page2() { global $colors, $heading, etc; $page = "<HTML>\n" ."<HEAD>\n" .etcetcetc ."</HTML>\n"; return $page; } This should work a bit better.

« previous php.general (#24423) next »