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