News Feed
Sections




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

DevShed:
Using the Clone Magic Function in PHP 5
June 15, 2009 @ 12:04:25

New on DevShed today is the latest article in their "magic functions" series. This time they focus on the "clone" method to create exact copies of current objects.

In this fifth part of a seven-part tutorial on magic functions, we'll briefly review the sleep and wakeup functions, and then tackle the clone function. [...] So, with that goal in mind, in this fifth part of the series I'm going to take a closer look at the "__clone()" method, which as its name suggests, is called behind the scenes when using the "clone" PHP keyword.

Their example code adds on to the previous examples using "__get" and "__set" and adds in a method to catch the cloning of an object. It only outputs a string ("Cloning user object") when its called, but it lets you get the idea.

0 comments voice your opinion now!
method magic tutorial clone


blog comments powered by Disqus

Similar Posts

IBM developerWorks: MVC with Agavi - Add forms and database support with Agavi and Doctrine

PHPMaster.com: Patterns for Flexible View Handling, Part 1 - Working with Composites

Zend Developer Zone: OSCON '07 Wrapup

Peter Goodman's Blog: Observers and Dispatchers

Profeshunl Newbie Blog: MongoDB as in huMONGOus, not retarded


Community Events

Don't see your event here?
Let us know!


symfony2 framework application release performance voicesoftheelephpant series interview podcast api php7 introduction version library extension opinion community laravel conference example

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework