Re: Formatting output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



listas@xxxxxxxxxxxxxxxxxxx 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux