3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Base { public function __construct() { $this->get(new StdClass); } private function get(StdClass $foo) { var_dump("Base"); } } class Child1 extends Base { public function get() { var_dump("Child"); } } class Child2 extends Base { public function __construct() { $this->get(); } public function get() { var_dump("Child"); } } new Base(); new Child1(); new Child2();
Output for 5.6.24 - 5.6.38, 7.0.10 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
string(4) "Base" string(4) "Base" string(5) "Child"
Output for 7.0.0 - 7.0.9
Warning: Declaration of Child1::get() should be compatible with Base::get(StdClass $foo) in /in/Rk7sS on line 17 Warning: Declaration of Child2::get() should be compatible with Base::get(StdClass $foo) in /in/Rk7sS on line 27 string(4) "Base" string(4) "Base" string(5) "Child"
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.23
Strict Standards: Declaration of Child1::get() should be compatible with Base::get(StdClass $foo) in /in/Rk7sS on line 17 Strict Standards: Declaration of Child2::get() should be compatible with Base::get(StdClass $foo) in /in/Rk7sS on line 27 string(4) "Base" string(4) "Base" string(5) "Child"

preferences:
229.9 ms | 402 KiB | 294 Q