note 101636 added to function.class-alias

From: Date: Fri, 31 Dec 2010 09:09:56 +0000
Subject: note 101636 added to function.class-alias
Groups: php.notes 
Request: Send a blank email to php-notes+get-175364@lists.php.net to get a copy of this message
At first, you might wonder that: <?php class A {}; class_alias('A', 'B'); ?> is equivalent to: <?php class A {}; class B extends A {}; ?> BUT when derivation creates a new class name - that means, you can then instantiate a new kind of objects - aliasing is just what it says: a synonym, so objects instantiated with the aliased name are of the exact same kind of objects instantiated with the non-aliased name. See this code for example: <?php class A {}; class B1 extends A {}; class_alias('A', 'B2'); $b1 = new B1; echo get_class($b1); // prints B1 $b2 = new B2; echo get_class($b2); // prints A ! ?> ---- Server IP: 89.31.146.176 Probable Submitter: 82.239.246.9 ---- Manual Page -- http://www.php.net/manual/en/function.class-alias.php Edit -- https://master.php.net/note/edit/101636 Del: integrated -- https://master.php.net/note/delete/101636/integrated Del: useless -- https://master.php.net/note/delete/101636/useless Del: bad code -- https://master.php.net/note/delete/101636/bad+code Del: spam -- https://master.php.net/note/delete/101636/spam Del: non-english -- https://master.php.net/note/delete/101636/non-english Del: in docs -- https://master.php.net/note/delete/101636/in+docs Del: other reasons-- https://master.php.net/note/delete/101636 Reject -- https://master.php.net/note/reject/101636 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#175364) next »