Simple object referencing question

liunx

Guest
Example:

$objA = $this->myCustomClass->someMethod(); // Returns an object
$objB = $this->myCustomClass->someOtherMethod(); // Returns the same object inside myCustomClass, with modified properties.

1) Will both $objA and $objB reference to the same return object?
2) Or $objA and $objB has each its own copy of the returned object?


If 1), then I'll need to use clone right?looks like that was a simple example you could have tested yourself :)

but indeed, you will need to clone; <!-- m --><a class="postlink" href="http://uk.php.net/language.oop5.cloningFor">http://uk.php.net/language.oop5.cloningFor</a><!-- m --> PHP5 the same object will be returned. For PHP 4 different objects will be returned unless you explicitly use the pass by reference notation.Thanks guys, just wanted to make sure
 
Back
Top