note 14078 added to language.references.return.php

From: Date: Mon, 16 Jul 2001 16:57:08 +0000
Subject: note 14078 added to language.references.return.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-15435@lists.php.net to get a copy of this message
As someone mentioned above, references can be used to combat the syntax: $z = do_something_to($z); If do_something_to() takes its argument by reference, you can simply say: do_something_to($z); However, this also can be error-prone since users of the function might not realize that the parameter is passed by reference, and they might be surprised when $z changes as a result of the function call. IMHO, the best solution is to use objects, and a method syntax: $z->doSomethingTo(); This makes it explicit that $z itself is being manipulated (not a copy of $z). If you find yourself always getting confused by references in PHP, perhaps you should consider a more object-oriented approach to what you are doing. http://www.php.net/manual/en/language.references.return.php

« previous php.notes (#15435) next »