I don't think it's a bug. This weird behavior is due to the Engine 1 object 
model (which will be different in Engine 2).

At 07:38 PM 2/12/2002 -0600, Jason Greene wrote:
>Zeev, Andi
>
>It appears that the bug we talked about in private correspondence does
>not just apply to object overloading. It appears to apply to normal
>objects as well.
>
>Consider the following code:
>
>class test {
>     var $dummy;
>
>     function do_something() {
>          print "Hello\n";
>     }
>
>}
>
>$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


>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

Reply via email to