3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function evalJS($code) { $code = preg_replace('#var #', '\$', $code); $code = preg_replace('#.#', '->', $code); $code = preg_replace('#(\'|")\+#', '$1.', $code); $code = preg_replace('#\+(\'|")#', '.$1', $code); eval($code); } class document { public function print($arg) { echo($arg); } } $js = <<<JS var foo = 'Hello '+'World!'; document.print(foo); JS; evalJS($js);
based on cP0sJ
Output for 7.0.0 - 7.2.0
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting end of file in /in/0R3Su(8) : eval()'d code on line 1
Process exited with code 255.
Output for 5.4.12 - 5.6.28
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/0R3Su on line 12
Process exited with code 255.
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected T_PRINT, expecting T_STRING in /in/0R3Su on line 12
Process exited with code 255.