On Wed, 2002-02-13 at 12:24, Andi Gutmans wrote: > >$obj=new test(); > > $obj == is_ref=1/refcount=1 > > >debug_zval_dump($obj); > > You are passing $obj by value. So inside the debug_zval_dump() it will be > is_ref=0/refcount=1 (it will be copied). > > > >$obj->do_something(); > > Inside do_something it will be is_ref=1/refcount=2 > > >debug_zval_dump($obj); > > You are passing $obj by value. So inside the debug_zval_dump() it will be > is_ref=0/refcount=1 (it will be copied). > > Bottom line: Passing it by value makes it duplicate. This is Engine 1. > Nothing to do about it. I guess debug_zval_dump() isn't that useful after > all :) > > Andi
Yes I do realize that the function would copy the value; however, I would think the output before and after $obj->do_something would be equal The problem I was mainly refering to is the reference count of the properties elements. Why would it grow from 2 to 3 after the call to $obj->do_somtehing? Why does the reference count of the object drop from 2 to 1 after the function is called? If I remove the line $obj->do_something I get the following. object(test)(1) refcount(2){ ["dummy"]=> long(1) refcount(2) } object(test)(1) refcount(2){ ["dummy"]=> long(1) refcount(2) } Perhaps I am missing something obvious? > > >This will produce the following output: > > > >object(test)(1) refcount(2){ > > ["dummy"]=> > > long(1) refcount(2) > >} > >Hello > >object(test)(1) refcount(1){ > > ["dummy"]=> > > long(1) refcount(3) > >} > > > >ZEND_SEND_VAR is the opcode that does this in this scenario as well > > > > > > > > > >-jason > > > > > > > >-- > >Jason T. Greene > >Internet Software Engineer > > > ><[EMAIL PROTECTED]> > ><[EMAIL PROTECTED]> > ><[EMAIL PROTECTED]> > > > >Use PHP: http://www.php.net > > > -- > PHP Development Mailing List <http://www.php.net/> > To unsubscribe, visit: http://www.php.net/unsub.php > -- Jason T. Greene Internet Software Engineer <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Use PHP: http://www.php.net -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php