TypePHP 编译器
https://swoole.com/aot/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
602 B
39 lines
602 B
--TEST--
|
|
ZE2 object cloning, 6
|
|
--INI--
|
|
error_reporting=2047
|
|
--FILE--
|
|
<?php
|
|
|
|
class MyCloneable {
|
|
static $id = 0;
|
|
|
|
function __construct() {
|
|
$this->id = self::$id++;
|
|
}
|
|
|
|
function __clone() {
|
|
$this->address = "New York";
|
|
$this->id = self::$id++;
|
|
}
|
|
}
|
|
function main() {
|
|
$original = new MyCloneable();
|
|
|
|
$original->name = "Hello";
|
|
$original->address = "Tel-Aviv";
|
|
|
|
echo $original->id . "\n";
|
|
|
|
$clone = clone $original;
|
|
|
|
echo $clone->id . "\n";
|
|
echo $clone->name . "\n";
|
|
echo $clone->address . "\n";
|
|
}
|
|
?>
|
|
--EXPECTF--
|
|
0
|
|
1
|
|
Hello
|
|
New York
|
|
|