note 50005 added to language.oop.newref
| From: | riseofthethorax at earthlink dot net | Date: | Tue, 15 Feb 2005 06:29:41 +0000 |
| Subject: | note 50005 added to language.oop.newref | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85053@lists.php.net to get a copy of this message | ||
Your examples fail to outline to me why copies are better than references, just in this example it
points out to me how bizarre coding processes can shoot you int he foot... You found one small
problem with using references, and found some example to exploit this problem so it would be an
issue.. I personally don't use globals for anything other than logging errors in modules.. I
might also use them for parameters.. But when I have a global to hang other objects off on, I just
do
global_object->add($my_object);
and in the global object I have
function add(& $object) {
$this->array[$this->counter] = &$object;
}
This global object is the implementation of a programming construct called a monitor.. Its better
than a
global because globals have no usage history, and you can embed in the call logging information to
track access in case you need to debug some temporal access problems..
So really you just introduced a decision to deprecate something based on your poor programming
habits..
Or is there a reason for it?
----
Manual Page -- http://www.php.net/manual/en/language.oop.newref.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50005
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50005&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50005&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50005&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50005&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50005&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50005&report=yes
Search -- http://master.php.net/manage/user-notes.php