hi
and sorry...I'm a C++ guy getting my brain messed up trying to figure out PHP =P
my problem is that that I can't seem to reference an object inside the constructor...
class Test {
var $_value;
function Test (&$elem, $value) {
$elem->setRef($this);
$this->setValue($value);
}
function setValue ($value) {
$this->_value=$value;
}
function getValue () {
return $this->_value;
}
}
class TestElement {
var $_ref;
function TestElement () {}
function setRef (&$ref) {
$this->_ref=&$ref;
}
function getTestValue () {
return $this->_ref->getValue();
}
}
$test_elem=new TestElement();
$test=new Test($test_elem, 6);
so...I have a instance of TestElement, and pass it to the constructor of Test, where it gets a reference to that instance of Test...
so TestElement::getTestValue() should return 6...
echo $test_elem->getTestValue();
output: 6
/me puts smile on his face
now lets change the value..
$test->setValue(7);
echo $test_elem->getTestValue();
output: 6
/me bashes head against wall...
why ?
$test_elem holds a reference to $test, thus, should return 7...
the PHP manual says nothing...or I'm blind...
can somebody give me a clue please ?
thanks in advance =D
/ I want my pointers back =( */