Hello,

I am developing a PHP extension. I can't reproduce the behavior of
references of Zend/PHP.

Here is some Code illustrating Zend's behavior:
<?php
class Foo { public $baz = array(1);}
$foo = new Foo();
$ref = &$foo->baz;
$foo->baz = [123];//set array has reference
var_dump($foo);

Output ------------------------
object(Foo)#1 (1) {
["baz"]=>
&array(1) { [0]=> int(123) }
}
--------------------------------
Note the symbol ( &) output from the var_dump();


Now I add unset($ref) in my code
<?php
class Foo { public $baz = array(1);}
$foo = new Foo();
$ref = &$foo->baz;
//unset($ref);// kill reference
$foo->baz = [123];// set array has reference
unset($ref) ;// kill reference
var_dump($foo);
------------------------
object(Foo)#1 (1) {
["baz"]=>
array(1) { [0]=> int(123) }
}
--------------------------------

Note that the symbol (&) has disappeared from the output of var_dump();

I would like to reproduce this behavior but I don't know which method of
zend_object_handlers allows to remove( Z_UNREF) the reference.

Thank you for your help

Reply via email to