function main() { $d = new D(); $d->testFoo1(); D::testFoo2(); $d->testBar1(); D::testBar2(); $b = new B(); $g = new G(); echo "############# doFoo ##############\n"; $b->doFoo(); $g->doFoo(); echo "############# doBar ##############\n"; $b->doBar(); $g->doBar(); }
self::bar(); // G G static::bar(); // G G echo "****************\n"; } } class H extends G { public function foo() { echo __CLASS__ . ' ' . get_called_class() . ' ' . (isset($this) ? get_class($this) : '') . "\n"; } public static function bar() { echo __CLASS__ . ' ' . get_called_class() . ' ' . (isset($this) ? get_class($this) : '') . "\n"; } } $d = new D(); $d->testFoo1(); D::testFoo2(); $d->testBar1(); D::testBar2(); $b = new B(); $g = new G(); echo "############# doFoo ##############\n"; $b->doFoo(); $g->doFoo(); echo "############# doBar ##############\n"; $b->doBar(); $g->doBar();