Fwd: FW: [PHP-DEV] print_r

From: Date: Wed, 01 Aug 2001 12:27:21 +0000
Subject: Fwd: FW: [PHP-DEV] print_r
Groups: php.dev 
Request: Send a blank email to php-dev+get-61740@lists.php.net to get a copy of this message
---------- Forwarded Message ---------- Subject: FW: [PHP-DEV] print_r Date: Wed, 1 Aug 2001 08:19:09 +0300 From: "Emanuel Dejanu" <edejanu@route66.ro> Sorry to forward this to you but I really have problems in printing a doubled linked class. Can you take a look at the following message and give me an answer. Thanks, Emanuel Dejanu -----Original Message----- From: Emanuel Dejanu [mailto:edejanu@route66.ro] Sent: Tuesday, July 31, 2001 9:22 AM To: php-dev@lists.php.net Subject: [PHP-DEV] print_r Hi, Is there a posibility to print an object but to not print some fields. If I use print_r he will print all variabiles from my object, but I want on variabile to not be printed. I do not want to write my own function. Ex. class Node { var $name; var $parent = '/' var $children = array(); function Node($name, &$parent) { $this->parent = &$parent; $this->name = $name; } } $rootNode = new Node('root', ''); array_push($rootNode->children, new Node('child1', $rootNode)); $child1Node = &$rootNode->children[0]; array_push($child1Node->children, new Node('child1', $child1Node)); print_r($rootNode); will print make a recursivity. What will be nice is to allow that some variabiles to not be printed like this: class Node { var $name; var $__parent = '/' var $children = array(); function Node($name, &$parent) { $this->__parent = &$parent; $this->name = $name; } } ..... /* add the root and childrens */ print_r($rootNode); will print now the corret tree. Bellow you find the only modification that need to be done for this to work. Best regards, Emanuel Dejanu File: Zend/zend.c static void print_hash(HashTable *ht, int indent) { zval **tmp; char *string_key; HashPosition iterator; unsigned long num_key, str_len; int i, key_type; /****** HERE *****/ for (i=0; i<indent; i++) { ZEND_PUTS(" "); } ZEND_PUTS("(\n"); indent += PRINT_ZVAL_INDENT; zend_hash_internal_pointer_reset_ex(ht, &iterator); while (zend_hash_get_current_data_ex(ht, (void **) &tmp, &iterator) == SUCCESS) { /******** HERE **************/ key_type = zend_hash_get_current_key_ex(ht, &string_key, &str_len, &num_key, 0, &iterator); if (key_type == HASH_KEY_IS_STRING) if (string_key[0] == '_' && string_key[1] == '_') continue; /******* HERE **************/ for (i=0; i<indent; i++) { ZEND_PUTS(" "); } ZEND_PUTS("["); switch (key_type) { case HASH_KEY_IS_STRING: ZEND_PUTS(string_key); break; case HASH_KEY_IS_LONG: zend_printf("%ld",num_key); break; } ZEND_PUTS("] => "); zend_print_zval_r(*tmp, indent+PRINT_ZVAL_INDENT); ZEND_PUTS("\n"); zend_hash_move_forward_ex(ht, &iterator); } indent -= PRINT_ZVAL_INDENT; for (i=0; i<indent; i++) { ZEND_PUTS(" "); } ZEND_PUTS(")\n"); } -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net -------------------------------------------------------

« previous php.dev (#61740) next »