In this article, you will learn how to create a copy of the object in PHP. The clone keyword in PHP is used to create a copy of an object.
examples of the CLONE keyword
Example 1. In this example, we create a copy of an object.
<?php
class MyClass {
public $color;
public $amount;
}
$obj = new MyClass();
$obj->color = "red";
$obj->amount = 5;
$copy = clone $obj;
print_r($copy);
?>