3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php interface Exp { public function x();} class First implements Exp { public function x() {} } class Second {} function x(Exp $e){ echo get_class($e)."\n"; } x(new First); x(new Second); ?>
based on TKk42
Output for 7.0.28 - 7.3.0rc3
First Fatal error: Uncaught TypeError: Argument 1 passed to x() must implement interface Exp, instance of Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F:7 Stack trace: #0 /in/qZU6F(11): x(Object(Second)) #1 {main} thrown in /in/qZU6F on line 7
Process exited with code 255.
Output for 5.6.38
First Catchable fatal error: Argument 1 passed to x() must implement interface Exp, instance of Second given, called in /in/qZU6F on line 11 and defined in /in/qZU6F on line 7
Process exited with code 255.