Home Bug Reports

bug when pass a class by value

slice:

class item;

sequence<item> items;
class item
{
string title;
items children;
};

...
item getitem();
...

server side implement code:

itemPtr getitem()
{
itemPtr i = new item;
i->title = "root";

itemPtr i2 = new item;
i2->title = "sub1";
i->children.push_back( i2 );

itemPtr i3 = new item;
i3->title = "sub2";
i2->children.push_back( i3 );

return i;
}


and PHP client side code:

$nav = $obj->getitem();

function dump_nav( $mynav, $level )
{
for ( $j = 0; $j != $level; ++ $j ) {
echo " ";
}
echo $mynav->title;
echo "<br/>";

$child_count = count($mynav->children);
for ( $i = 0; $i != $child_count; ++ $i ) {
ftr_dump_nav( $mynav->children[ i ], level + 1 );
}
}

dump_nav( $nav, 0 );

PHP client result:

"root
"

the well result is:

"root
sub1
sub2"

help me, please.

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    If you execute the following statement, you'll see that the object graph is being preserved correctly in PHP:
    print_r($nav);
    
    There is a bug in your code which is preventing it from displaying the graph. The corrected line is shown below:
    ftr_dump_nav( $mynav->children[ $i ], $level + 1 );
    
    Take care,
    - Mark
  • damingyipaidamingyipai Member ✭✭
    I see, sorry for my harum-scarum

    :-)
Sign In or Register to comment.