note 106958 added to language.oop5.traits

From: Date: Wed, 21 Dec 2011 08:42:38 +0000
Subject: note 106958 added to language.oop5.traits
Groups: php.notes 
Request: Send a blank email to php-notes+get-185188@lists.php.net to get a copy of this message
It may be worth noting here that the magic constant __CLASS__ becomes even more magical - __CLASS__ will return the name of the class in which the trait is being used. for example <?php trait sayWhere { public function whereAmI() { echo __CLASS__; } } class Hello { use sayWHere; } class World { use sayWHere; } $a = new Hello; $a->whereAmI(); //Hello $b = new World; $b->whereAmI(); //World ?> The magic constant __TRAIT__ will giev you the name of the trait ---- Server IP: 92.48.74.199 Probable Submitter: 213.123.137.121 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.traits.php Edit -- https://master.php.net/note/edit/106958 Del: integrated -- https://master.php.net/note/delete/106958/integrated Del: useless -- https://master.php.net/note/delete/106958/useless Del: bad code -- https://master.php.net/note/delete/106958/bad+code Del: spam -- https://master.php.net/note/delete/106958/spam Del: non-english -- https://master.php.net/note/delete/106958/non-english Del: in docs -- https://master.php.net/note/delete/106958/in+docs Del: other reasons-- https://master.php.net/note/delete/106958 Reject -- https://master.php.net/note/reject/106958 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#185188) next »