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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]