Hello,

        I am trying to get ob_start to work the way I expect but I am running
into some problems.

        Take the following example code:


/* Start of code snippet */
function ob_spit_content_length ($buffer) {
        $len=strlen($buffer);
        if($len>0) Header( "Content-Length: $len" );
        return $buffer;
}

if( !function_exists("ob_end_clean_all") ) {
        function ob_end_clean_all () {
                while ( ob_get_level() ) {
                        ob_end_clean();
                }
        }
}

ob_start("ob_spit_content_length");
ob_start("ob_gzhandler");

print "There is lots of stuff right here!";

ob_end_clean_all();

/* End of code snippet */

I am running PHP 4.3.0 and my desire is to compress all output (if
browser supports) and also send the content-length header rather than
sending chunked so that my output looks as close to static as possible.

My understanding is that ob_start can be nested and since I registered
"ob_spit_content_length" first and then "ob_gzhandler" second that
"ob_gzhandler" will run first and therefor $buffer being send to
"ob_spit_content_length" with either be clear text "browser does not
support compression" or the compress version of the page.  Either way
strlen will get me my length.

Well I get very strang effects and as soon as I comment out my 2 ob_start
calls every think works fine.  Often times op_spit_content_length will
say 0 bytes even though I *KNOW* output was sent.

Am I missing something here?  Did I layer things wrong?  Any suggestions
would be much appreciated.

Thanks,
Serge.

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

Reply via email to