Can anyone explain why is the get_class function returning different values below? Specifically, what is it supposed to do when it is called in a base class and whe
It seems quite well explained in the documentation, but here it is:
get_class($instance) returns the class of the $instance instance, regardless of where you're calling it; get_class($this) does behave the same way, returning the class of $this.
get_class() returns the class where the method calling it is defined, thus it returns bar in your example, as that is where __construct() is defined (even though you're calling it through inheritance).