PHP clone Keyword (ok)

https://www.w3schools.com/php/keyword_clone.asp

<!DOCTYPE html>
<html>
<body>

<?php
class MyClass {
  public $color;
  public $amount;
}

$obj = new MyClass();
$obj->color = 'red';
$obj->amount = 5;
$copy = clone $obj;
print_r($copy);
?>

</body>
</html>

<!DOCTYPE html>
<html>
<body>

<?php
class MyClass {
  public $color;
  public $amount;
}

$obj = new MyClass();
$obj->color = 'red';
$obj->amount = 5;
$copy = clone $obj;
print_r($copy);
?>

</body>
</html>
<!DOCTYPE html>
<html>
<body>

<?php
class MyClass {
  public $color;
  public $amount;
}

$obj = new MyClass();
$obj->color = 'red';
$obj->amount = 5;
$copy = clone $obj;
print_r($copy);
?>

</body>
</html>

MyClass Object
(
    [color] => red
    [amount] => 5
)

Last updated