Take care when using the optional second parameter $length!
In our tests -at least in certain situations- we were unable to determine the actual use of this parameter, plus, it lead to the script either being unable to inflate compressed data or crash due to memory-problems.
Example:
When trying to inflate the compressed data from a website, we were literally unable to find a value (other than 0) for $length in order to make gzinflate work... while without the second parameter (or setting it to 0) gzinflate worked like a charm:
<?php
gzinflate( substr($deflated_body, 10) );
gzinflate( substr($deflated_body, 10), 200 * strlen($deflated_body) );
gzinflate( substr($deflated_body, 10), 32768 * strlen($deflated_body) );
gzinflate( substr($deflated_body, 10), 11000 );
gzinflate( substr($deflated_body, 10), 280000000 ); =>
Warning: gzinflate() [function.gzinflate]: insufficient memory in [...]
gzinflate( substr($deflated_body, 10), 300000000 ); =>
Fatal error: Allowed memory size of 314572800 bytes exhausted (tried to allocate 300000000 bytes) in
?>
In short: We were unable to determine the actual use of the second parameter in certain situations.
Be careful with using the second parameter $length!