PHP 4.0 Bug #9453 Updated: Reference issue
| From: | mailling at bigfoot dot com | Date: | Thu, 08 Mar 2001 19:55:45 +0000 |
| Subject: | PHP 4.0 Bug #9453 Updated: Reference issue | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48304@lists.php.net to get a copy of this message | ||
ID: 9453
User Update by: mailling@bigfoot.com
Old-Status: Feedback
Status: Open
Bug Type: Scripting Engine problem
Description: Reference issue
let's run this code
<?php
class A{
function &b(&$f) {
$d=&$f;
$f='5';
return $d;
}
}
$c='3';
$d=new A();
$h=$d->b($c);
//$h=&$d->b($c); //The & is needed to work well
//we get $h=&$c;
$h='9';
echo $c. ' '.$h;
//since we should see 9 9, but we can see 5 9
?>
we get 5 9
If we adapt the code to:
//$h=$d->b($c);
$h=&$d->b($c); //The & is needed to work well
we get 9 9, and that should be the good value, rigth?
Previous Comments:
---------------------------------------------------------------------------
[2001-03-08 06:38:51] stas@php.net
Works for me. What are the results in your case?
---------------------------------------------------------------------------
[2001-02-26 05:07:37] mailling@bigfoot.com
I tried it with: allow_call_time_pass_reference = Off and allow_call_time_pass_reference = On
It seems that the result is not send automatically as a reference
class A{
function &b(&$f) {
$d=&$f;
$f='5';
return $d;
}
}
$c='3';
$d=new A();
$h=$d->b($c);
$h=&$d->b($c); //The & is needed to work well
$h='9';
echo $c. ' '.$h;
The value of c is not updated correctly if we don't ask for a reference
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=9453