blob: 2059103bc5aa0d93a228270e75b559ba9d63d85f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
--TEST--
ZE2 object cloning, 4
--FILE--
<?php
abstract class base {
public $a = 'base';
// disallow cloning
private function __clone() {}
}
class test extends base {
public $b = 'test';
// reenable cloning
public function __clone() {}
public function show() {
var_dump($this);
}
}
echo "Original\n";
$o1 = new test;
$o1->a = array(1,2);
$o1->b = array(3,4);
$o1->show();
echo "Clone\n";
$o2 = clone $o1;
$o2->show();
echo "Modify\n";
$o2->a = 5;
$o2->b = 6;
$o2->show();
echo "Done\n";
?>
--EXPECT--
Original
object(test)#1 (2) {
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
["a"]=>
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
}
Clone
object(test)#2 (2) {
["b"]=>
array(2) {
[0]=>
int(3)
[1]=>
int(4)
}
["a"]=>
array(2) {
[0]=>
int(1)
[1]=>
int(2)
}
}
Modify
object(test)#2 (2) {
["b"]=>
int(6)
["a"]=>
int(5)
}
Done
|