PHP 4.0 Bug #4415: Nested obj ref in array doesn't see scalar changes
| From: | holloway at io dot com | Date: | Fri, 12 May 2000 02:22:31 +0000 |
| Subject: | PHP 4.0 Bug #4415: Nested obj ref in array doesn't see scalar changes | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-18630@lists.php.net to get a copy of this message | ||
From: holloway@io.com
Operating system: Linux RedHat 6.0
PHP version: 4.0 Release Candidate 2
PHP Bug Type: Scripting Engine problem
Bug description: Nested obj ref in array doesn't see scalar changes
<?
class B {
var $_x;
function B($val) {
$this->_x = $val;
}
function getVal() {
return $this->_x;
}
function setVal ($v) {
$this->_x = $v;
}
}
class A {
var $_bObjArr;
var $_b;
function A ($value) {
// Creates a new B object.
$this->_b = new B($value);
// Should copy its reference pointer to element
// 1 of an array.
$this->_bObjArr[1] = $this->_b;
}
function setBValInArr($value) {
$tmp_bobj = $this->_bObjArr[1];
$tmp_bobj->setVal($value);
}
function setScalarBVal($value) {
$this->_b->setVal($value);
}
function getScalarVal () {
return $this->_b->getVal();
}
function getArrVal () {
$tmp_b = $this->_bObjArr[1];
return $tmp_b->getVal();
}
}
// Inside A object constructor, instantiates a B object, sets value of its
// $_x variable to 4, creates a copy of its reference pointer into an
// array.
$a = new A(4);
print "B obj. instantiated with x value 4.<br><br>";
print "Scalar retrieved value = " . $a->getScalarVal() . "<br>";
print "Array pointer retrieved value = " . $a->getArrVal() .
"<br><br>";
$a->setScalarBVal(99);
print "\$_x set to <b>99</b> by SCALAR, retrieved by SCALAR. ";
print "Retrieved value = <b>" . $a->getScalarVal() .
"</b><br><br>";
$a->setScalarBVal(99);
print "\$_x set to <b>99</b> by SCALAR, retrieved by ARRAY PTR. ";
print "Retrieved value = <b>" . $a->getArrVal() .
"</b><br><br>";
$a->setBValInArr(99);
print "\$_x set to <b>99</b> by ARRAY PTR, retrieved by SCALAR. ";
print "Retrieved value = <b>" . $a->getScalarVal() .
"</b><br><br>";
$a->setBValInArr(99);
print "\$_x set to <b>99</b> by ARRAY PTR, retrieved by ARRAY PTR. ";
print "Retrieved value = <b>" . $a->getArrVal() .
"</b><br><br>";
?>
I configured PHP 4.0RC2 as static with configure line
./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars --enable-track-sid
I don't think my php.ini is relevant. I'll be glad to provide it.