3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '((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; } print "\nexpr = " . $expr; print "\nres = " . $result;
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
expr = ((800+20)-800/2) Notice: Undefined variable: result in /in/RO80Z on line 27 res =
Output for 4.3.0 - 5.0.3
expr = ((800+20)-800/2) Notice: Undefined variable: result in /in/RO80Z on line 27 res =