__CLASS__
Code can get complex. Inheritance and variable variables can lead to confusion. Sometimes it’s nice just to know what happened where. That’s were these magic constants come in handy most often and here’s another one.
The constant __CLASS__ will give you the name of the class it’s in. The case is preserved. It works anywhere in the class.
class Monkey_Test { const class_name = __CLASS__; public function monKey() { return "I'm in: " . __CLASS__; } static public function butLer() { return "I'm in: " . __CLASS__; } } echo Monkey_Test::class_name; // Monkey_Test echo Monkey_Test::butLer(); // I'm in: Monkey_Test $m = new Monkey_Test(); echo $m->monKey(); // I'm in: Monkey_Test

Giorgio Sironi wrote,
Note that __CLASS__ is substituted at bytecode compile time, so if you use subclasses you may replace it with get_class($this); however that does not work in static methods.
Link | May 18th, 2009 at 10:32