PHP supports the Late Static Bindings mechanism. The full class name with static inheritance we can get by calling the function:
1 |
get_called_class() |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<?php class Parent { public static function getName() { echo get_called_class(); } } class Child extends Parent { } Parent::getName(); Child::getName(); ?> // Parent // Child |