compression gzip

Hello. After ob_start(); for gzip is required ob_flush or ob_end_flush? How does it work if not flush?

Next question:
Why on some servers with:

ini_set(‘zlib.output_compression’,‘On’)

ob_get_level return 1 and gzip works well, but ob_get_level should return 2… ?

You are confusing two things: output buffering, and gzip. They do not happen at the same time, and they are completely independent (unless you explicitely tie them together, which I personally sometimes do).

For your first question: if you run to the end of the scope where ob_start was started, ob_flush will be called automatically. For instance, if you have this:
[php]function blah() {
ob_start();
echo “test”;
}
blah();[/php]

You will see blah on the screen.

ob_get_level allows you to get something called the level of nesting of your output buffer. Take the following example:

[php]function A () { ob_start(); B(); }
function B() { ob_start(); C(); }
function C() { echo ob_get_level(); }
A();[/php]

This will echo 2. A() is called in scope 0, opens ob_start() and calls B(). B is therefore in level 1. B calls ob_start(), calls C, C is therefore in level 2. That is what ob_get_level is for: it allows you to know how many output buffers are on top of the one you are currently in.

gzip is completely independent of all this. It runs after PHP has done executing or on every chunk, depending on how your request was formulated to the interpreter. It is completely transparent and there is no way to know that it is running outside of config flags.

Sponsor our Newsletter | Privacy Policy | Terms of Service