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

# PHP clone Keyword (ok)

```
<!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
)
```
