3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = '$x=0; ((800 + 20) - 800 / 2)'; $tokens = token_get_all("<?php {$input}"); $expr = ''; foreach($tokens as $token){ if(is_string($token)){ if(in_array($token, array('(', ')', '+', '-', '/', '*'), true)) $expr .= $token; continue; } list($id, $text) = $token; if(in_array($id, array(T_DNUMBER, T_LNUMBER))) $expr .= $text; } eval("\$result = {$expr};"); print "\nexpr = " . $expr; print "\nres = " . $result;
based on q5DaK
Output for 7.0.0 - 7.3.0beta1
Parse error: syntax error, unexpected '(' in /in/4VfJf(24) : eval()'d code on line 1
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Function name must be a string in /in/4VfJf(-1)(925bef6e5800fefb52edbfbe82941122) : eval()'d code:-1 Stack trace: #0 /in/4VfJf(-1): include() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: Function name must be a string in /in/4VfJf(24)(925bef6e5800fefb52edbfbe82941122) : eval()'d code:1 Stack trace: #0 /in/4VfJf(24): include() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Parse error: syntax error, unexpected '(' in /in/4VfJf(24) : eval()'d code on line 1 expr = 0((800+20)-800/2) Notice: Undefined variable: result in /in/4VfJf on line 27 res =