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(new StdClass); } public function get() { var_dump("Child"); } } new Base(); new Child1(); new Child1();
Output for 5.6.24 - 5.6.40, 7.0.10 - 7.0.33, 7.1.0 - 7.1.33, 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.6
string(4) "Base" string(4) "Base" string(4) "Base"
Output for 7.0.0 - 7.0.9
Warning: Declaration of Child1::get() should be compatible with Base::get(StdClass $foo) in /in/JTZUc on line 17 Warning: Declaration of Child2::get() should be compatible with Base::get(StdClass $foo) in /in/JTZUc on line 27 string(4) "Base" string(4) "Base" string(4) "Base"
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/JTZUc on line 17 Strict Standards: Declaration of Child2::get() should be compatible with Base::get(StdClass $foo) in /in/JTZUc on line 27 string(4) "Base" string(4) "Base" string(4) "Base"

preferences:
270.74 ms | 402 KiB | 330 Q