3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '((\'rats\' + \'stoats\') - 800 / 2)'; $tokens = token_get_all("<?php {$input}"); $expr = ''; foreach($tokens as $token){ print "\ntokens = " . $tokens; 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,T_CONSTANT_ENCAPSED_STRING))){ $expr .= $text; print "\n number: " . $expr; } } eval("\$result = {$expr};"); print "\nexpr = " . $expr; print "\nres = " . $result;
Output for 7.1.0
Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: ( Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (( Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats' Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+ Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats' Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats') Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')- Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats')-800 Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')-800/ Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats')-800/2 Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')-800/2) Warning: A non-numeric value encountered in /in/Vh5mB(28) : eval()'d code on line 1 Warning: A non-numeric value encountered in /in/Vh5mB(28) : eval()'d code on line 1 expr = (('rats'+'stoats')-800/2) res = -400
Output for 5.4.0 - 7.0.14
Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: ( Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (( Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats' Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+ Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats' Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats') Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')- Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats')-800 Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')-800/ Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array number: (('rats'+'stoats')-800/2 Notice: Array to string conversion in /in/Vh5mB on line 10 tokens = Array symbol: (('rats'+'stoats')-800/2) expr = (('rats'+'stoats')-800/2) res = -400
Output for 4.3.0 - 5.3.29
tokens = Array tokens = Array symbol: ( tokens = Array symbol: (( tokens = Array number: (('rats' tokens = Array tokens = Array symbol: (('rats'+ tokens = Array tokens = Array number: (('rats'+'stoats' tokens = Array symbol: (('rats'+'stoats') tokens = Array tokens = Array symbol: (('rats'+'stoats')- tokens = Array tokens = Array number: (('rats'+'stoats')-800 tokens = Array tokens = Array symbol: (('rats'+'stoats')-800/ tokens = Array tokens = Array number: (('rats'+'stoats')-800/2 tokens = Array symbol: (('rats'+'stoats')-800/2) expr = (('rats'+'stoats')-800/2) res = -400