Annotation of embedaddon/php/tests/classes/clone_006.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: ZE2 object cloning, 6
! 3: --SKIPIF--
! 4: <?php if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed'); ?>
! 5: --INI--
! 6: error_reporting=2047
! 7: --FILE--
! 8: <?php
! 9:
! 10: class 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:
! 28: echo $original->id . "\n";
! 29:
! 30: $clone = clone $original;
! 31:
! 32: echo $clone->id . "\n";
! 33: echo $clone->name . "\n";
! 34: echo $clone->address . "\n";
! 35:
! 36: ?>
! 37: --EXPECT--
! 38: 0
! 39: 1
! 40: Hello
! 41: New York
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>