3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Go { public function if (bool $cond): Go { return $this; } public function then(callable $func): Go { return $this; } } $go = (new Go)->if(5 > 3)->then(function () {echo 'YAY!';}); var_dump($go);
Output for 7.0.0 - 7.2.0
object(Go)#1 (0) { }
Output for 5.4.12 - 5.6.28
Parse error: syntax error, unexpected 'if' (T_IF), expecting identifier (T_STRING) in /in/6vm2c on line 4
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected T_IF, expecting T_STRING in /in/6vm2c on line 4
Process exited with code 255.