PHP clone Keyword

Trusted SSL from just $3.44
Advertisements
PHP const Keyword
PHP class Keyword

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);
?>
PHP const Keyword
PHP class Keyword
close

Stay up-to-date about PHP!

We don’t spam!

Trusted SSL from just $3.44
Advertisements
Trusted SSL from just $3.44
Advertisements

en English
X
Scroll to Top