Output buffering
am 07.10.2009 09:37:30 von Arno Kuhl
Has there been a change to the way output buffering works?
The manual states for ob_get_contents()
"This will return the contents of the output buffer or FALSE, if output
buffering isn't active."
But the following works in php4.4.4 and php5.2.6 whether output buffering is
on or not
ob_start();
echo "
";
echo "output_buffering is ";
echo ini_get('output_buffering')?"on":"off";
echo "";
$check = ob_get_contents();
if ($check === FALSE)
echo " FALSE";
$info = ob_get_contents();
ob_clean();
echo $info." -2-";
ob_flush();
?>
The output is "output_buffering is off -2-" (or on) displayed once - "FALSE"
is obviously never appended.
According to the manual I shouldn't see anything at all when
output_buffering is off (or if memory serves me correctly I should see an
error about "headers already sent" or something). Looking at phpinfo
confirms the value echoed by the script. Has something changed with output
buffering?
Cheers
Arno
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Output buffering
am 07.10.2009 10:54:20 von David Otton
2009/10/7 Arno Kuhl :
> According to the manual I shouldn't see anything at all when
> output_buffering is off (or if memory serves me correctly I should see an
> error about "headers already sent" or something). Looking at phpinfo
> confirms the value echoed by the script. Has something changed with output
> buffering?
Use
echo ob_get_level() . "
";
to find out how many levels of output buffering you are wrapped in.
Whether output buffering is set to start automatically, and whether
output buffering is on right now are two different things:
ob_end_clean();
echo ob_get_level() . "
";
echo ini_get('output_buffering') . "
";
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
RE: Output buffering
am 07.10.2009 11:34:19 von Arno Kuhl
From: djotto@gmail.com [mailto:djotto@gmail.com] On Behalf Of David Otton
Sent: 07 October 2009 10:54 AM
To: arno@dotcontent.net
Cc: php-general@lists.php.net
Subject: Re: [PHP] Output buffering
2009/10/7 Arno Kuhl :
> According to the manual I shouldn't see anything at all when
> output_buffering is off (or if memory serves me correctly I should see
> an error about "headers already sent" or something). Looking at
> phpinfo confirms the value echoed by the script. Has something changed
> with output buffering?
Use
echo ob_get_level() . "
";
to find out how many levels of output buffering you are wrapped in.
Whether output buffering is set to start automatically, and whether output
buffering is on right now are two different things:
ob_end_clean();
echo ob_get_level() . "
";
echo ini_get('output_buffering') . "
";
--
Thanks David. After taking another look at the description for ob_start() I
began to suspect there was a difference, but the manual doesn't mention
anything about it. And the fact they use the same terminolgy for both the
settings and the functions is confusing. I can see from tests that the
htaccess/ini settings have no obvious effect on the ob functions (maybe
buffer size?).
Cheers
Arno
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Output buffering
am 07.10.2009 12:51:10 von David Otton
2009/10/7 Arno Kuhl :
> Thanks David. After taking another look at the description for ob_start() I
> began to suspect there was a difference, but the manual doesn't mention
> anything about it. And the fact they use the same terminolgy for both the
> settings and the functions is confusing. I can see from tests that the
> htaccess/ini settings have no obvious effect on the ob functions (maybe
> buffer size?).
My understanding (and it's not 100% clear in the manual) is that the
output buffering directive is overloaded - it can be used for both
turning output buffering on and setting the size of the output buffer.
Quote:
; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP's output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of 'On', as
; a value for this directive (e.g., output_buffering=4096).
output_buffering = 4096
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Output buffering
am 07.10.2009 15:08:56 von Shawn McKenzie
Arno Kuhl wrote:
>
> Thanks David. After taking another look at the description for ob_start() I
> began to suspect there was a difference, but the manual doesn't mention
> anything about it. And the fact they use the same terminolgy for both the
> settings and the functions is confusing. I can see from tests that the
> htaccess/ini settings have no obvious effect on the ob functions (maybe
> buffer size?).
>
> Cheers
> Arno
>
The ini setting tells PHP to automatically start output buffering at the
beginning of each script. If it is off and you execute an ob_start() to
start buffering, the ini setting will still be off.
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php