cvs: php4 /ext/standard var.c

From: Date: Sat, 15 Dec 2001 14:46:02 +0000
Subject: cvs: php4 /ext/standard var.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8659@lists.php.net to get a copy of this message
derick Sat Dec 15 09:46:02 2001 EDT Modified files: /php4/ext/standard var.c Log: - Added a second parameter to var_export which makes the function return the variable representation in a string. Index: php4/ext/standard/var.c diff -u php4/ext/standard/var.c:1.123 php4/ext/standard/var.c:1.124 --- php4/ext/standard/var.c:1.123 Tue Dec 11 10:30:37 2001 +++ php4/ext/standard/var.c Sat Dec 15 09:45:59 2001 @@ -202,26 +202,27 @@ /* }}} */ -/* {{{ proto void var_export(mixed var) - Dumps a string representation of variable to output */ +/* {{{ proto mixed var_export(mixed var [, int return]) + Outputs or returns a string representation of avariable */ PHP_FUNCTION(var_export) { - zval ***args; - int argc; - int i; + zval *var; + long i = 0; - argc = ZEND_NUM_ARGS(); - - args = (zval ***)emalloc(argc * sizeof(zval **)); - if (ZEND_NUM_ARGS() == 0 || zend_get_parameters_array_ex(argc, args) == FAILURE) { - efree(args); - WRONG_PARAM_COUNT; + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|l", &var, &i) == FAILURE) { + return; } - for (i=0; i<argc; i++) - php_var_export(args[i], 1 TSRMLS_CC); + if (i) { + php_start_ob_buffer (NULL, 0); + } - efree(args); + php_var_export(&var, 1 TSRMLS_CC); + + if (i) { + php_ob_get_buffer (return_value); + php_end_ob_buffer (0, 0); + } } /* }}} */

« previous php.cvs (#8659) next »