|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-01-05 09:20 UTC] alex_boyer at hotmail dot com
[2004-02-03 13:43 UTC] andi@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 22:00:02 2025 UTC |
Description: ------------ $that is not available in parent class B (uncomment code in class A you will see it). So it is not possible to clone class in a recursive way. Reproduce code: --------------- class A { public $a; function __clone(){ //if( $that === null ) die('$that is null'); $this->a = $that->a; } } class B extends A { public $b; function __clone(){ parent::__clone(); $this->b = $that->b; } } $b = new B(); $b->a = 'AAA'; $b->b = 'BBB'; $clone = $b->__clone(); print_r($clone); Expected result: ---------------- B Object ( [b] => BBB [a] => AAA ) Actual result: -------------- B Object ( [b] => BBB [a] => )