summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerick Rethans <derick@php.net>2002-07-25 11:22:20 +0000
committerDerick Rethans <derick@php.net>2002-07-25 11:22:20 +0000
commitb7cc9f7447bbe090b337befe32e6019ef9f4c840 (patch)
tree942d3bca4e3029c4ab4be9869e2c4376bacf53e8
parent3e05678842e7451d01639446e6097a042de5e192 (diff)
downloadphp-git-b7cc9f7447bbe090b337befe32e6019ef9f4c840.tar.gz
- 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)
-rw-r--r--ext/standard/basic_functions.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 633f2cb0df..67f5958b1a 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -2077,19 +2077,29 @@ PHP_FUNCTION(ini_restore)
}
/* }}} */
-/* {{{ 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;
+ }
}
/* }}} */