Hi Folks,
I've been using the "passing arguments by reference" thingie for a while
now. But what I want to do know is something I'm used to using in perl,
returning a reference.
Situation is as follows.
3 <?php
4 # EXAMPLE
5 Class Foo {
6 function Foo() {
7 }
8
9 function SomeThing() {
10 $this->Changed = "sure";
11 }
12
13 };
14
15 Class Bar {
16 function Bar() {
17
18 }
19
20 function AddFoo() {
21 $Ref = &$this->Foos[];
22 $Ref = new Foo();
23 return $Ref;
24 }
25 };
26
27 $Bar = new Bar();
28 $Foo = $Bar->AddFoo();
29 $Foo->SomeThing();
30
31 print_r($Bar);
32 print_r($Foo);
33 ?>
And this is the output:
bar Object
(
[Foos] => Array
(
[0] => foo Object
(
)
)
)
foo Object
(
[Changed] => sure
)
The $Foo->SomeThing() call changes the $Foo instance, and what I want it to
do is change the instance of Foo that is nested within $Bar. So that the
output would be like:
bar Object
(
[Foos] => Array
(
[0] => foo Object
(
[Changed] => sure
)
)
)
foo Object
(
[Changed] => sure
)
Sure hope to find any help in here .. Been breaking my head on this matter
for a while.
Thanks!
Wouter
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php