News Feed
Sections




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

DZone.com:
Cloning in PHP
May 17, 2013 @ 11:09:42

In this recent post over on DZone.com Giorgio Sironi takes a look at the "clone" feature of PHP - what it is, how it can be used and things to watch out for in its use.

Cloning is an operation consisting in the duplication of a data structure, usually to avoid the aliasing problem of having different code modify the same instance in inconsistent ways. In PHP, cloning can be accomplished in multiple ways - and in some cases it can be avoided altogether.

He talks some about how objects are passed around internally during the PHP execution and how you can tell if a function works with data by reference (from the manual). He then looks at the "clone" keyword and what kinds of things are duplicated from an object when it is used. He briefly touches on the "__clone" magic method for solving the "shallow clone" problem and how, possibly, serializing the object might be a better alternative for reproducing the entire object.

0 comments voice your opinion now!
clone introduction object reference serialize shallow deep

Link: http://css.dzone.com/articles/cloning-php

blog comments powered by Disqus

Similar Posts

PHPFreaks.com: Sessions and cookies: Adding state to a stateless protocol

Script-Tutorials.com: Functional Programming - How to Write Functional Code in PHP

DevShed: Fetching Search Results as Serialized Arrays with Yahoo Web Services and PHP 5

Allan MacGregor: Playing with dependency injection in PHP

PHPMac.com: Two New Tutorials (an Intro and MySQL/Forms)


Community Events





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


list wordpress bugfix framework introduction release code developer podcast interview api series configure laravel application library project language community threedevsandamaybe

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