Re: Formatting output

From: Date: Mon, 11 Jun 2007 13:02:08 +0000
Subject: Re: Formatting output
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-256594@lists.php.net to get a copy of this message
listas@fernandomarcelo.com wrote:
I would like to format the output of a PHP page into a single line and use gzip compression too. I know that i can use something like this to get in a single line ( will workout on this function later to remove spaces ). <?php function my_function( $buffer ) {
                $str = str_replace( "\n" , " " , $buffer );
return $str; } ob_start("my_function"); echo 'hello'; ob_end_flush(); ?> And gzip compression is used with <?php ob_start("ob_gzhandler"); echo 'hello'; ob_end_flush(); ?> Is there a way to "mix" those codes?
Output buffers can be stacked. So simply start the gzip bugger with ob_start, then call it again with your handler. The handlers will be called in reverse order when the buffers get flushed. BTW, you don't need to ob_end_flush at the end of a script - this gets done automagically when the script ends. -Stut

« previous php.general (#256594) next »