PHP 4.0 Bug #9481: Passing out class property by reference problem
| From: | phil at kusala dot com | Date: | Tue, 27 Feb 2001 15:42:35 +0000 |
| Subject: | PHP 4.0 Bug #9481: Passing out class property by reference problem | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-47625@lists.php.net to get a copy of this message | ||
From: phil@kusala.com
Operating system: Linux (Redhat 6.2) on an i686
PHP version: 4.0.4pl1
PHP Bug Type: Scripting Engine problem
Bug description: Passing out class property by reference problem
<?
function xmpdump($xValue, $sLabel="")
{
echo "$sLabel<xmp>";
var_dump($xValue);
echo "</xmp>";
}
class test
{
var $sValue;
var $Count = 0;
function getTest(&$refObj)
{
if (isset($this->sValue))
{
$refObj = &$this->sValue;
xmpdump($refObj, "Reference before being passed back");
return;
}
else
{
$refObj = "phil".$this->Count;
$this->Count++;
$this->sValue = &$refObj;
xmpdump($refObj, "Value before being passed back");
return;
}
}
}
$tst = new test();
$tst->getTest($tstObj0);
xmpdump($tstObj0, "Value after being passed back");
$tst->getTest($tstObj1);
xmpdump($tstObj1, "Refence after being passed back");
?>
The dump of $tstObj1 is NULL, despite the dump of $refObj immediately before it in the function
working correctly.
--
Edit Bug report at: http://bugs.php.net/?id=9481&edit=1