cvs: php4 /ext/standard basic_functions.c

From: Date: Thu, 25 Jul 2002 11:22:20 +0000
Subject: cvs: php4 /ext/standard basic_functions.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-12978@lists.php.net to get a copy of this message
derick Thu Jul 25 07:22:20 2002 EDT Modified files: /php4/ext/standard basic_functions.c Log: - Added parameter to print_r which returns the variable representation instead of echoing it. @- Added parameter to print_r which returns the variable representation @ instead of echoing it. (Derick) Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.486 php4/ext/standard/basic_functions.c:1.487 --- php4/ext/standard/basic_functions.c:1.486 Tue Jul 16 10:14:22 2002 +++ php4/ext/standard/basic_functions.c Thu Jul 25 07:22:20 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.486 2002/07/16 14:14:22 jason Exp $ */ +/* $Id: basic_functions.c,v 1.487 2002/07/25 11:22:20 derick Exp $ */ #include "php.h" #include "php_streams.h" @@ -2077,19 +2077,29 @@ } /* }}} */ -/* {{{ proto bool print_r(mixed var) - Prints out information about the specified variable */ +/* {{{ proto bool print_r(mixed var [, bool return]) + Prints out or returns information about the specified variable */ PHP_FUNCTION(print_r) { - pval **expr; + zval *var; + zend_bool i = 0; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &expr) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|b", &var, &i) == FAILURE) { + return; + } + + if (i) { + php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC); } - zend_print_pval_r(*expr, 0); + zend_print_pval_r(var, 0); - RETURN_TRUE; + if (i) { + php_ob_get_buffer (return_value TSRMLS_CC); + php_end_ob_buffer (0, 0 TSRMLS_CC); + } else { + RETURN_TRUE; + } } /* }}} */

« previous php.cvs (#12978) next »