3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class base_class { function say_a() { echo "'a' - said the " . __CLASS__ . "<br/>"; } function say_b() { echo "'b' - said the " . get_class($this) . "<br/>"; } } class derived_class extends base_class { function say_a() { parent::say_a(); echo "'a' - said the " . __CLASS__ . "<br/>"; } function say_b() { parent::say_b(); echo "'b' - said the " . get_class($this) . "<br/>"; } } $obj_b = new derived_class(); $obj_b->say_a(); echo "<br/>"; $obj_b->say_b();
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
'a' - said the base_class<br/>'a' - said the derived_class<br/><br/>'b' - said the derived_class<br/>'b' - said the derived_class<br/>