3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = '$x=100; ((800 + 20) - 800 / 2)'; $tokens = token_get_all("<?php {$input}"); $expr = ''; foreach($tokens as $token){ echo $token."<br>"; if(is_string($token)){ if(in_array($token, array('(', ')', '+', '-', '/', '*','if','IF' , '{' ,'}' , ';' ,'$'), 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 K8heR
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.21.3, 7.0.0 - 7.3.0beta1
Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>=<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>;<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>(<br>(<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>+<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>)<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>-<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>/<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br> Notice: Array to string conversion in /in/cs1pv on line 9 Array<br>)<br> expr = 100;((800+20)-800/2) res = 100
Output for hhvm-3.22.0
Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>=<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>;<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>(<br>(<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>+<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>)<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>-<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>/<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br> Notice: Array to string conversion in /in/cs1pv on line -1 Array<br>)<br> expr = 100;((800+20)-800/2) res = 100