mirror of
https://github.com/php/php-src.git
synced 2024-12-18 06:21:41 +08:00
44 lines
535 B
PHP
44 lines
535 B
PHP
--TEST--
|
|
ZE2 object cloning, 2
|
|
--FILE--
|
|
<?php
|
|
class test {
|
|
public $p1 = 1;
|
|
public $p2 = 2;
|
|
public $p3;
|
|
public function __clone() {
|
|
}
|
|
};
|
|
|
|
$obj = new test;
|
|
$obj->p2 = 'A';
|
|
$obj->p3 = 'B';
|
|
$copy = clone $obj;
|
|
$copy->p3 = 'C';
|
|
echo "Object\n";
|
|
var_dump($obj);
|
|
echo "Clown\n";
|
|
var_dump($copy);
|
|
echo "Done\n";
|
|
?>
|
|
--EXPECT--
|
|
Object
|
|
object(test)#1 (3) {
|
|
["p1"]=>
|
|
int(1)
|
|
["p2"]=>
|
|
string(1) "A"
|
|
["p3"]=>
|
|
string(1) "B"
|
|
}
|
|
Clown
|
|
object(test)#2 (3) {
|
|
["p1"]=>
|
|
int(1)
|
|
["p2"]=>
|
|
string(1) "A"
|
|
["p3"]=>
|
|
string(1) "C"
|
|
}
|
|
Done
|