I learned that static is better than self because self does late static binding.
But I wonder which would be best at referencing const variable.
class Black
{
const color = 'black';
public function byThis()
{
return $this::color;
}
public function bySelf()
{
return self::color;
}
public function byStatic()
{
return static::color;
}
}
I checked all of three getters work well. Which is the best choice? (I use PHP 7.0)
byThis()
andbyStatic()
will return the subclass's value. – Handoff