xref: /PHP-5.3/tests/classes/clone_006.phpt (revision 610c7fbe)
1--TEST--
2ZE2 object cloning, 6
3--SKIPIF--
4<?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
5--INI--
6error_reporting=2047
7--FILE--
8<?php
9
10class MyCloneable {
11	static $id = 0;
12
13	function MyCloneable() {
14		$this->id = self::$id++;
15	}
16
17	function __clone() {
18		$this->address = "New York";
19		$this->id = self::$id++;
20	}
21}
22
23$original = new MyCloneable();
24
25$original->name = "Hello";
26$original->address = "Tel-Aviv";
27
28echo $original->id . "\n";
29
30$clone = clone $original;
31
32echo $clone->id . "\n";
33echo $clone->name . "\n";
34echo $clone->address . "\n";
35
36?>
37--EXPECT--
380
391
40Hello
41New York
42