I have a class a and instantiated it using new
$obja = new a;
I know the difference between the below two lines
$obja2 = $ojba;
$obja2 = clone $obja;
But even if you declare or not declare __clone in the class a the first line $obja2 refer to $obja memory space and second line creates a copy of the $obja. Till here it is clear to me.
Then why php is having a magic method __clone?
Is it only for executing a set of codes which is written inside __clone while we use $obja2 = clone $obja;
Somebody please help to get a better idea of it.
So yes, it’s a callback after the
cloneoperation has finished. Nothing more, nothing less.