3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait EndpointInjector { public function before($str) { echo $str; } } class Endpoint { use EndpointInjector; public function test($boringObj) { return $boringObj->withBody('#'); } } class BoringObj { public function withBody($str) { return $str; } } $ep = new Endpoint(); $ep->before(); $ep->test(new BoringObj());
based on KRnFU
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Endpoint::before(), 0 passed in /in/93pHc on line 30 and exactly 1 expected in /in/93pHc:5 Stack trace: #0 /in/93pHc(30): Endpoint->before() #1 {main} thrown in /in/93pHc on line 5
Process exited with code 255.
Output for 5.4.10 - 7.0.20
Warning: Missing argument 1 for Endpoint::before(), called in /in/93pHc on line 30 and defined in /in/93pHc on line 5 Notice: Undefined variable: str in /in/93pHc on line 7
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_STRING in /in/93pHc on line 3
Process exited with code 255.