Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Acko.net:
PHP 5 References Fun
Sep 24, 2004 @ 12:06:21

In a quick note from Steven's blog is a pointer to tricky problem with the clone keyword in PHP 5- "There is a nasty change in PHP5: objects are now always passed by reference. Variables hold a handle to the object rather than the object itself. This brings PHP more in line with other OO languages (like Java) and removes some of the ugly from PHP OO code, but it also means that objects are treated differently from all the other types. Old code that depends on having objects copied when not passed by reference will break." For the fix, go here.

This issue reared its ugly head when they were working on Drupal when they remembered that objects are handled this way. A solution? The "clone" keyword creates a copy of the object to pass along. Oddly enough, there are times when this would come in quite handy - especially on a project like Drupal.

Thanks to PHP Magazine for the link...

tagged:

Link:


Trending Topics: