xref: /PHP-8.2/tests/classes/clone_001.phpt (revision f8d79582)
1--TEST--
2ZE2 object cloning, 1
3--FILE--
4<?php
5class test {
6    public $p1 = 1;
7    public $p2 = 2;
8    public $p3;
9};
10
11$obj = new test;
12$obj->p2 = 'A';
13$obj->p3 = 'B';
14$copy = clone $obj;
15$copy->p3 = 'C';
16echo "Object\n";
17var_dump($obj);
18echo "Clown\n";
19var_dump($copy);
20echo "Done\n";
21?>
22--EXPECT--
23Object
24object(test)#1 (3) {
25  ["p1"]=>
26  int(1)
27  ["p2"]=>
28  string(1) "A"
29  ["p3"]=>
30  string(1) "B"
31}
32Clown
33object(test)#2 (3) {
34  ["p1"]=>
35  int(1)
36  ["p2"]=>
37  string(1) "A"
38  ["p3"]=>
39  string(1) "C"
40}
41Done
42