> I have a problem with pointers in php.
They're not pointers.
PHP is not C.
It happens to look C, but it's not.
> In the following code the parent object should be a pointer to class Main
> ($this), but it's a copy ...
It's an alias, not a pointer.
> <?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
>
Style Tip:
Add var $A; var $B;
> function Main() {
>
> $this->A = new Sub_A($this);
I *think* you want &$this as the argument to do what you are trying to do...
>
> $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>";
>
> ?>
Bottom Line: It's not C. Don't expect it to work exactly like C.
--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
--
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]