Section 11.7. Other OB Functions


11.7. Other OB Functions

The ob_get_length( ) and ob_get_level( ) functions both take no parameters and return a number. For ob_get_length( ), the return value is the number of bytes held in the buffer, and for ob_get_level( ), it is the nest count . This returns 0 if you are not within an output buffer, 1 if you have one open, 2 if you have two, etc.

Using ob_get_level( ), it is possible to recursively close and flush/clean all open buffers if you have an error. The ob_get_length( ) function is helpful if you want to send a custom HTTP Content-Length headeralthough that is for advanced users only!

Finally, the ob_list_handlers( ) function takes no parameters and returns an array of any output handlers currently in effect. If output buffering is turned on, you should get back an array containing the default output handler; if you're using gzip to compress your buffer, you should get "ob_gzhandler"; and if you've used URL rewriting, you should get "URL-Rewriter".



PHP in a Nutshell
Ubuntu Unleashed
ISBN: 596100671
EAN: 2147483647
Year: 2003
Pages: 249

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net