Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Shon Levi
Shon Levi
6,036 Points

Little explanation for CLONE command

Hey you there, I'll be glad to get some explanation for the use of CLONE...

What is the differences between these:

$object2 = $object1;

$obect2 = clone $obect1;

Thanks

1 Answer

Shon Levi
Shon Levi
6,036 Points

I get the idea - clone is duplicate object without affect the original. The difference between the two above is that if I will run a method on the copy, the original will get affect too, with clone it will affect only the copy.

Thanks anyway and hope it will help someone in the future :)