note 11008 deleted from language.oop by victor
| From: | victor@php.net | Date: | Sat, 07 Dec 2002 15:45:53 +0000 |
| Subject: | note 11008 deleted from language.oop by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40479@lists.php.net to get a copy of this message | ||
[SORRY my last post wasn't complete,
please delete it...]
SUBJECT: php and "call by reference"
Referencing Objects in PHP ist a nightmare ;-) There is almost nothing about this in the manual.
To get the same behaviour in php as it is in Java (where you have "call by reference" by
default) use the following syntax:
* add & to all variables you don't
want to copy, but refer to.
[$first = &second]
-> this _is_ in the manual, I'm only
adding it for completeness.
* add & to all variables in a function
-declaration you don't want to copy
"into" the function but refer to
them from inside the function.
[function foo(&$first, &$second) {}]
* add & to all function-declarations
in case you want the functions to
_return_ referenced variables as
well (!)
[function &foo(&$first, &$second){}]
Now it seems possible to write REAL OO-code like in Java. But still, the more complex structures
(built using the above) get, there are strange effects like mixed up object-references sometimes.
Ferdinand
[Sorry for my english...]