Hi,
I have a problem with pointers in php.
In the following code the parent object should be a pointer to class Main
($this), but it's a copy ...
Any ideas ?
Thx Chris
<?php
class Sub_A {
// constructor
function Sub_A(&$parent) {
$this->parent = &$parent;
}
function Modify($text) {
$this->parent->B->text = $text;
}
}
class Sub_B {
var $text = "untouched";
// constructor
function Sub_B(&$parent) {
$this->parent = &$parent;
}
}
class Main {
// constructor
function Main() {
$this->A = new Sub_A($this);
$this->B = new Sub_B($this);
}
}
$test = new Main();
$test->A->Modify('test');
// this method should work, but doesnt (should return "test" instead of
"untouched")
echo $test->B->text."<br>";
// parent isnt a pointer but a copy so absolute addressing works
echo $test->A->parent->B->text."<br>";
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]