3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '((\ln(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; print "\n symbol: " . $expr; } continue; } list($id, $text) = $token; if(in_array($id, array(T_DNUMBER, T_LNUMBER))){ $expr .= $text; print "\n number: " . $expr; } } eval("\$result = {$expr};"); print "\nexpr = " . $expr; print "\nres = " . $result;
Output for 5.3.0 - 7.1.0
symbol: ( symbol: (( symbol: ((( number: (((800 symbol: (((800) symbol: (((800)+ number: (((800)+20 symbol: (((800)+20) symbol: (((800)+20)- number: (((800)+20)-800 symbol: (((800)+20)-800/ number: (((800)+20)-800/2 symbol: (((800)+20)-800/2) expr = (((800)+20)-800/2) res = 420
Output for 4.3.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/hLVFQ on line 5 symbol: ( symbol: (( symbol: ((( number: (((800 symbol: (((800) symbol: (((800)+ number: (((800)+20 symbol: (((800)+20) symbol: (((800)+20)- number: (((800)+20)-800 symbol: (((800)+20)-800/ number: (((800)+20)-800/2 symbol: (((800)+20)-800/2) expr = (((800)+20)-800/2) res = 420