php call static method from class

Solutions on MaxInterview for php call static method from class by the best coders in the world

showing results for - "php call static method from class"
Lara
20 Sep 2016
1class static_test_class {
2    public static function test() {
3        echo "Original class\n";
4    }
5
6    public static function run($use_self) {
7        if($use_self) {
8            self::test();
9        } else {
10            $class = get_called_class();
11            $class::test(); 
12        }
13    }
14}
15
16class extended_static_test_class extends static_test_class {
17    public static function test() {
18        echo "Extended class\n";
19    }
20}
21
22extended_static_test_class::run(true);
23extended_static_test_class::run(false);