cvs: php4 /ext/standard var.c
| From: | Derick Rethans | Date: | Thu, 14 Mar 2002 18:41:35 +0000 |
| Subject: | cvs: php4 /ext/standard var.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-10127@lists.php.net to get a copy of this message | ||
derick Thu Mar 14 13:41:35 2002 EDT
Modified files:
/php4/ext/standard var.c
Log:
- Fix bug #16078
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.133 php4/ext/standard/var.c:1.134
--- php4/ext/standard/var.c:1.133 Thu Mar 14 09:05:13 2002
+++ php4/ext/standard/var.c Thu Mar 14 13:41:35 2002
@@ -271,6 +271,21 @@
return 0;
}
+static int php_object_element_export(zval **zv, int num_args, va_list args, zend_hash_key
*hash_key)
+{
+ int level;
+ TSRMLS_FETCH();
+
+ level = va_arg(args, int);
+
+ if (hash_key->nKeyLength != 0) {
+ php_printf("%*cvar $%s = ", level + 1, ' ', hash_key->arKey);
+ }
+ php_var_export(zv, level + 2 TSRMLS_CC);
+ PUTS (";\n");
+ return 0;
+}
+
void php_var_export(zval **struc, int level TSRMLS_DC)
{
HashTable *myht;
@@ -299,20 +314,28 @@
break;
case IS_ARRAY:
myht = Z_ARRVAL_PP(struc);
- goto head_done;
- case IS_OBJECT:
- myht = Z_OBJPROP_PP(struc);
-head_done:
if (level > 1) {
php_printf("\n%*c", level - 1, ' ');
}
PUTS ("array (\n");
zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_array_element_export, 1, level);
if (level > 1) {
- php_printf("%*c", level-1, ' ');
+ php_printf("%*c", level - 1, ' ');
}
PUTS(")");
break;
+ case IS_OBJECT:
+ myht = Z_OBJPROP_PP(struc);
+ if (level > 1) {
+ php_printf("\n%*c", level - 1, ' ');
+ }
+ php_printf ("class %s {\n", ((*struc)->value.obj.ce)->name);
+ zend_hash_apply_with_arguments(myht, (apply_func_args_t) php_object_element_export, 1, level);
+ if (level > 1) {
+ php_printf("%*c", level - 1, ' ');
+ }
+ PUTS("}");
+ break;
default:
PUTS ("NULL");
break;
@@ -323,7 +346,7 @@
/* {{{ proto mixed var_export(mixed var [, bool return])
- Outputs or returns a string representation of avariable */
+ Outputs or returns a string representation of a variable */
PHP_FUNCTION(var_export)
{
zval *var;