]> granicus.if.org Git - php/commitdiff
Added ob_get_clean() and ob_get_flush().
authorYasuo Ohgaki <yohgaki@php.net>
Thu, 3 Oct 2002 01:36:44 +0000 (01:36 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Thu, 3 Oct 2002 01:36:44 +0000 (01:36 +0000)
Someone requested this feature before.
@ Added ob_get_clean() and og_get_flush(). (Yasuo)

ext/standard/basic_functions.c
main/output.c
main/php_output.h

index 5512154e84d8171f7a6741908d269bc3af8aa105..28b720320065ec1d74cfc647b36e333787e0b719 100644 (file)
@@ -750,6 +750,8 @@ function_entry basic_functions[] = {
        PHP_FE(ob_clean,                                                                                                                NULL)
        PHP_FE(ob_end_flush,                                                                                                    NULL)
        PHP_FE(ob_end_clean,                                                                                                    NULL)
+       PHP_FE(ob_get_flush,                                                                                                    NULL)
+       PHP_FE(ob_get_clean,                                                                                                    NULL)
        PHP_FE(ob_get_length,                                                                                                   NULL)
        PHP_FE(ob_get_level,                                                                                                    NULL)
        PHP_FE(ob_get_status,                                                                                                   NULL)
index 35e8988a3342c98c782e01115f57426a0d668ae9..8b1c8bc680549e1e3f86990c6f079321f1396c61 100644 (file)
@@ -821,6 +821,56 @@ PHP_FUNCTION(ob_end_clean)
 }
 /* }}} */
 
+/* {{{ proto bool ob_get_flush(void)
+   Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
+PHP_FUNCTION(ob_get_flush)
+{
+       if (ZEND_NUM_ARGS() != 0)
+                       WRONG_PARAM_COUNT;
+
+       /* get contents */
+       if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+               RETURN_FALSE;
+       }
+       /* error checks */
+       if (!OG(ob_nesting_level)) {
+               php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush.");
+               RETURN_FALSE;
+       }
+       if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
+               php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+               RETURN_FALSE;
+       }
+       /* flush */
+       php_end_ob_buffer(1, 0 TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool ob_get_clean(void)
+   Get current buffer contents and delete current output buffer */
+PHP_FUNCTION(ob_get_clean)
+{
+       if (ZEND_NUM_ARGS() != 0)
+                       WRONG_PARAM_COUNT;
+               
+       /* get contents */
+       if (php_ob_get_buffer(return_value TSRMLS_CC)==FAILURE) {
+               RETURN_FALSE;
+       }
+       /* error checks */
+       if (!OG(ob_nesting_level)) {
+               php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer. No buffer to delete.");
+               RETURN_FALSE;
+       }
+       if (OG(ob_nesting_level) && !OG(active_ob_buffer).status && !OG(active_ob_buffer).erase) {
+               php_error_docref("ref.outcontrol" TSRMLS_CC, E_NOTICE, "failed to delete buffer %s.", OG(active_ob_buffer).handler_name);
+               RETURN_FALSE;
+       }
+       /* delete buffer */
+       php_end_ob_buffer(0, 0 TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto string ob_get_contents(void)
    Return the contents of the output buffer */
 PHP_FUNCTION(ob_get_contents)
index 0c485e834c86e249bf3bff00383e515fa778f926..99810802caf155af5ccf3da2f5ae0ce8b4bdb271 100644 (file)
@@ -47,6 +47,8 @@ PHP_FUNCTION(ob_flush);
 PHP_FUNCTION(ob_clean);
 PHP_FUNCTION(ob_end_flush);
 PHP_FUNCTION(ob_end_clean);
+PHP_FUNCTION(ob_get_flush);
+PHP_FUNCTION(ob_get_clean);
 PHP_FUNCTION(ob_get_contents);
 PHP_FUNCTION(ob_get_length);
 PHP_FUNCTION(ob_get_level);