In PHP, I know two methods of displaying the name of the current class being called: through the magic constant __CLASS__
and the get_called_class()
function.
Apparently, they both do the same thing.
class A
{
public static function className()
{
echo get_called_class();
}
}
class B
{
public static function className()
{
echo __CLASS__;
}
}
B::className(); // 'B'
A::className(); // 'A'
Is there a performance difference between them?
Is there a difference in calling them?