note 8951 deleted from language.oop by danbrown

From: Date: Sat, 07 Nov 2009 19:04:34 +0000
Subject: note 8951 deleted from language.oop by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-162578@lists.php.net to get a copy of this message
Note Submitter: iw at warped dot nu ---- Here's a very important reminder to those of you used to Java/C++ object references/pointers. When you send a function arguments which include a class object, PHP will make copies of that object for use inside that function. This differs from passing a Java reference to an object or passing a C++ pointer to an object. Within the scope of the above-mentioned function, calling class methods of the argument object will only affect the copy that PHP creates. Likewise, when the function itself is completed, the copy of the object you passed ceases to exist. To emulate Java/C++ functionality of arguments that are objects, you just have to modify the given function's signature from this: function foo(..., $object, ...) to this: function foo(..., &$object, ...) The ampersand(&) thus signifies that the function should receive a reference to the object, instead of creating a copy of the object.

« previous php.notes (#162578) next »