PHP 8.5.0 Alpha 4 available for testing

Voting

: min(zero, four)?
(Example: nine)

The Note You're Voting On

Hayley Watson
17 years ago
It should go without saying that if you have circular references, where a property of object A refers to object B while a property of B refers to A (or more indirect loops than that), then you'll be glad that clone does NOT automatically make a deep copy!

<?php

class Foo
{
var
$that;

function
__clone()
{
$this->that = clone $this->that;
}

}

$a = new Foo;
$b = new Foo;
$a->that = $b;
$b->that = $a;

$c = clone $a;
echo
'What happened?';
var_dump($c);

<< Back to user notes page

To Top