Re: Output buffering
| From: | Wico de Leeuw | Date: | Thu, 03 Aug 2000 13:56:18 +0000 |
| Subject: | Re: Output buffering | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-9926@lists.php.net to get a copy of this message | ||
At 14:17 3-8-00 +0100, Darren Beale wrote:
ob_start; shoulf be one the first line before anything else that outputs something not in the function Hi do you mean that I cannot output anything to the browser? _at_all_<? ob_start; //output here you want to capture $output = ob_get_contents(); ob_end_clean(); // erase everything from buffer echo $output; write $output to file ?> something like that that everything after the ob_end_clean will be outputted as normal and you will have the var $output with the data before the clean so you can do both :) Greetz, Wico
I've moved ob_start out of the function, but I still get output of html_header to the browser? <? function top_code($lev) { html_header("Hello"); $output = ob_get_contents(); return $output; } $build_home_index = @fopen($index_page,"w"); if (!$build_home_index) { print "\n<li>Error opening " . $index_page . " for writing!"; } else { ob_start; @fputs($build_home_index,top_code($lev)); @fputs($build_home_index,show_categories()); @fputs($build_home_index,bottom_code()); ob_end_clean(); print "\n<li>" . $front_end_url . "/index.php - Built"; } fclose($build_home_index); ?> tia Bealers