xref: /PHP-7.0/tests/classes/clone_001.phpt (revision 610c7fbe)
1--TEST--
2ZE2 object cloning, 1
3--SKIPIF--
4<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
5--FILE--
6<?php
7class test {
8	public $p1 = 1;
9	public $p2 = 2;
10	public $p3;
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