note 114333 added to language.oop5.traits
| From: | tomasz at marcinkowski dot pl | Date: | Sun, 09 Feb 2014 23:05:30 +0000 |
| Subject: | note 114333 added to language.oop5.traits | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-198441@lists.php.net to get a copy of this message | ||
Unlike the __CLASS__ constant, which returns name of a class implementing a trait, the __METHOD__
constant returns the trait method name. You might find it useful.
Example:
<?php
namespace XXX;
trait Ta {
public function test1() {
return sprintf('class: %s, method: %s, trait: %s', __CLASS__, __METHOD__, __TRAIT__);
}
}
class A {
use Ta;
}
$a = new A();
var_dump($a->test1()); // class: XXX\A, method: XXX\Ta::test1, trait: XXX\Ta
?>
----
Server IP: 72.52.91.14
Probable Submitter: 72.52.91.14
----
Manual Page -- http://php.net/manual/en/language.oop5.traits.php
Edit -- https://master.php.net/note/edit/114333
Del: integrated -- https://master.php.net/note/delete/114333/integrated
Del: useless -- https://master.php.net/note/delete/114333/useless
Del: bad code -- https://master.php.net/note/delete/114333/bad+code
Del: spam -- https://master.php.net/note/delete/114333/spam
Del: non-english -- https://master.php.net/note/delete/114333/non-english
Del: in docs -- https://master.php.net/note/delete/114333/in+docs
Del: other reasons-- https://master.php.net/note/delete/114333
Reject -- https://master.php.net/note/reject/114333
Search -- https://master.php.net/manage/user-notes.php