Re: Re: New object model
| From: | Marek Kilimajer | Date: | Thu, 15 Jul 2004 07:02:32 +0000 |
| Subject: | Re: Re: New object model | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190574@lists.php.net to get a copy of this message | ||
Jason Barnett wrote:
Although you can turn on zend engine 1 compatibility, if you intend to distribute your code you cannot expect this on most servers. Another way to pass by value is to use the __clone method. function test($orig, $clone) { $orig->x = 'I am the original.'; $clone->x = 'I am a clone.'; print_r($orig); // should be different since this is a copy, not a reference print_r($clone); } class foo {} $orig = new foo(); test($orig, $orig->__clone());Fatal error: Cannot call __clone() method on objects - use 'clone $obj' instead... Should be: test($orig, clone($orig));