note 113553 deleted from language.oop5.traits by cmb

From: Date: Tue, 08 Sep 2015 19:45:50 +0000
Subject: note 113553 deleted from language.oop5.traits by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-203740@lists.php.net to get a copy of this message
Note Submitter: atorich at gmail dot com ---- add to "chris dot rutledge at gmail dot com": __CLASS__ will return the name of the class in which the trait is being used (!) not the class in which trait method is being called: <?php trait TestTrait { public function testMethod() { echo "Class: " . __CLASS__ . PHP_EOL; echo "Trait: " . __TRAIT__ . PHP_EOL; } } class BaseClass { use TestTrait; } class TestClass extends BaseClass { } $t = new TestClass(); $t->testMethod(); //Class: BaseClass //Trait: TestTrait

« previous php.notes (#203740) next »