No. You have "get_value_from" and "to_merge_with" names pointing to the
same zval. Tmp is another zval. You've lost here zval "get_value_from" was
pointing to. You have now no idea what it was.
yeah you got it (and did not knew ;) ) and that´s the idea, the reason, the purpose.
I *don´t* need the zval from $to_merge_with, I´m just interested in reference
bindings and I want to merge another reference to the group of bound references
and then bind them all together to another zval.
That´s important for OO stuff only.
What did you want to do? Copy one zval to another? There's much more
simple way to do this. If you meant to copy references, you didn't do
that.
it was a bug ;) I published that code without testing it, I was in rush too, forgive me...
here´s the corrected version which *copies* references (I`m rush again, hope there´s no bug again)
<?php
function &re_link(&$to_merge_with,&$get_value_from) {
$tmp=$get_value_from; // save value
$get_value_from=&$to_merge_with; // now you´ve linked all the three but lost the value
$get_value_from=$tmp; // restore the value
return $get_value_from;
}
$tmp=5;
$tmp2=&$tmp;
$tmp3=&$tmp;
$tmp4=&$tmp;
$variable_which_is_now_a_reference_2_tmp=&testcase($tmp);
echo $tmp;
?><BR><?php
echo $tmp==$variable_which_is_now_a_reference_2_tmp;
$tmp4=6;
//var_dump($GLOBALS);
?><BR><?php
echo $tmp==$variable_which_is_now_a_reference_2_tmp;
function &testcase(&$tmp) {
$variable_which_would_like_to_be_a_reference_2_tmp='foooo';
$variable_which_would_like_to_be_a_reference_2_tmp=&re_link($tmp,$variable_which_would_like_to_be_a_reference_2_tmp);
return $variable_which_would_like_to_be_a_reference_2_tmp; }
--
o----------0-¬---------O-·---¬----o---®-----o o O ° .
| http://www.kiffen.de | pRoteçt y0ur bRaín |0 O ° ¤ °
·
0°·³°²'²³-¹'³´³°^°³~³²³°'³²²¨³²^³¹³²°²³`³º³°Þ °
o © ° . ·
| psychedelic experience | gott@kiffen.de | O ° o °
o-¬--o--0-----©-·--O-----o-----0-¤----------o 0 ° · ° . ¤ ·