Skip to Main Content
PHP in a Nutshell
book

PHP in a Nutshell

by Paul Hudson
October 2005
Intermediate to advanced content levelIntermediate to advanced
372 pages
11h 35m
English
O'Reilly Media, Inc.
Content preview from PHP in a Nutshell

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 header—although 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".

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP Cookbook

PHP Cookbook

Eric A. Mann
Programming PHP

Programming PHP

Rasmus Lerdorf, Kevin Tatroe
Learning PHP

Learning PHP

David Sklar

Publisher Resources

ISBN: 0596100671Errata Page