3v4l.org

run code in 300+ PHP versions simultaneously
<?php set_error_handler( function ($code, $string) { throw new Exception($string, $code); } ); try { interface I1 {} interface I2 {} class A implements I1 { public function fn() { echo 'foo'; } } class B extends A implements I2 { public function fn($arg) { echo $arg; } } } catch (Exception $e) { // ignore } $b = new B(); var_dump($b instanceof I1); // outputs "bool(false)" var_dump($b instanceof I2); // outputs "bool(false)" var_dump(class_implements('B')); // outputs "array(1) { 'I1' => string(2) "I1" }" $b->fn('bar'); // outputs "bar"
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Fatal error: Declaration of B::fn($arg) must be compatible with A::fn() in /in/fkbOC on line 13
Process exited with code 255.
Output for 7.4.0 - 7.4.33
bool(true) bool(true) array(2) { ["I1"]=> string(2) "I1" ["I2"]=> string(2) "I2" } bar
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
bool(true) bool(false) array(1) { ["I1"]=> string(2) "I1" } bar

preferences:
134.22 ms | 408 KiB | 5 Q