diff options
author | Yasuo Ohgaki <yohgaki@php.net> | 2002-10-03 01:36:44 +0000 |
---|---|---|
committer | Yasuo Ohgaki <yohgaki@php.net> | 2002-10-03 01:36:44 +0000 |
commit | bd177ce7c1b4a9d73fc38c4f41e6001085ad882d (patch) | |
tree | cfec444b1d1791f7d30244c7dda0c952d79df759 /main/output.c | |
parent | 01830c0d272d321752a60e81245f8098d0d279b3 (diff) | |
download | php-git-bd177ce7c1b4a9d73fc38c4f41e6001085ad882d.tar.gz |
Added ob_get_clean() and ob_get_flush().
Someone requested this feature before.
@ Added ob_get_clean() and og_get_flush(). (Yasuo)
Diffstat (limited to 'main/output.c')
-rw-r--r-- | main/output.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/main/output.c b/main/output.c index 35e8988a33..8b1c8bc680 100644 --- a/main/output.c +++ b/main/output.c @@ -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) |