Code: Select all
abstract class AbstractClass
{
public function foo()
{
return class_name($this);
# class_name(); gives just "AbstractClass"
}
public static function bar()
{
return class_name($this);
}
}
class ConcreteClassOne extends AbstractClass
{
public function test_non_static()
{
return foo(); # gives "ConcreteClassOne"
}
public static function test_static()
{
# doesn't work because there's not an instance of the class, obviously
# However, I would like to find a way of getting "ConcreteClassOne" as the return value in this context
return bar();
}
}
class ConcreteClassTwo extends AbstractClass
{
public function test_non_static()
{
return foo(); # gives "ConcreteClassTwo"
}
public static function test_static()
{
# See above
return bar();
}
}