Re: RFC on ob_get/ob_end_clean, was Re: [PHP-CVS] cvs: php4 /ext/session session.c ...
| From: | Yasuo Ohgaki | Date: | Fri, 01 Mar 2002 09:46:05 +0000 |
| Subject: | Re: RFC on ob_get/ob_end_clean, was Re: [PHP-CVS] cvs: php4 /ext/session session.c ... | ||
| References: | 1 2 | Groups: | php.cvs php.dev |
| Request: | Send a blank email to php-dev+get-80546@lists.php.net to get a copy of this message | ||
It nice to have and +1 for this.
string ob_get_contents(int $option = 0)
--
Yasuo Ohgaki
Hartmut Holzgraefe wrote:
Yasuo Ohgaki wrote:Added ob_get_status() to get array of buffers and it's status. (DO NOT document this function yet)from looking at the codebase here in our company i find that we have just two use cases for the ob_...() stuff: - calling ob_start("callback") only and have callback() do the all the work on script termination - or the following sequence:Fixed crash bug with ob_end_*() function. ob_end_*() will not deletebuffers that may not be deleted.php_start_ob_buffer() and php_ob_set_internal_handler() takes parameter forif the buffer created may be deleted or not.Added 3rd parameter "bool erase" to ob_start(). If FALSE, buffer may not bedeleted until script finshes.Changed ob_*() function that have void return type to bool. All ob_*() functions return TRUE for success, FALSE for failure.ob_start(); /* some output */; $var = ob_get_contents(); ob_clean();especiallyob_start(); print_r($var); error_log(ob_get_contents()); ob_end_clean();so i've been thinking about a combination of of ob_get_contents() and ob_end_clean() for a long time i have come up with several different naming/implementation variants - a new function - string ob_get_clean(void) or - string ob_end_get(void) - an optional boolean parameter to an existing function - string ob_get_contents(bool $clean = false) or - string ob_end_clean(bool $return_contents = false) - an optional int parameter to an existing functions and some predefined constants - string ob_get_contents(int $option = 0)with OB_NONE -> no operation (0)OB_CLEAN -> clean output bufferOB_FLUSH -> flush output bufferOB_END -> end output buffering (current level)OB_APPLY_CALLBACK -> apply callback registered with ob_start, if any, on returned buffer contents