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);
Output for 7.0.0 - 7.2.0
Warning: preg_replace(): No ending delimiter '#' found in /in/cP0sJ on line 7
Output for 5.4.12 - 5.6.28
Parse error: syntax error, unexpected 'print' (T_PRINT), expecting identifier (T_STRING) in /in/cP0sJ 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/cP0sJ on line 12
Process exited with code 255.