3
In PHP, I know two methods to display the name of the current class being called: through the magic constant __CLASS__
and function get_called_class()
.
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'
There is a difference in performance between them?
Is there any difference when calling them?
The answer was a little simple, but I’ll try to complement later.
– Guilherme Nascimento
But that’s what I’ve been waiting for :)
– Wallace Maxters