]> granicus.if.org Git - php/commitdiff
- Added a second parameter to var_export which makes the function return
authorDerick Rethans <derick@php.net>
Sat, 15 Dec 2001 14:45:59 +0000 (14:45 +0000)
committerDerick Rethans <derick@php.net>
Sat, 15 Dec 2001 14:45:59 +0000 (14:45 +0000)
  the variable representation in a string.

ext/standard/var.c

index 56e7e9bc962fbf8ea5f6ce7fdd16d5dd84b5776c..0f9a41e25e8877a18f62875578bd354ddb591015 100644 (file)
@@ -202,26 +202,27 @@ head_done:
 /* }}} */
 
 
-/* {{{ 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);
+       }
 }
 /* }}} */