3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $input = '((800 + {$test->value}) - 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; print "\ntoken=".$token; if(in_array($id, array(T_DNUMBER, T_LNUMBER))) $expr .= $text; } //eval("\$result = {$expr};"); print "\nexpr = " . $expr; //print "\nres = " . $result;
Output for 5.4.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array Notice: Array to string conversion in /in/B6v45 on line 19 token=Array expr = ((800+{})-800/2)
Output for 4.3.0 - 5.0.5, 5.1.1 - 5.3.29
token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array token=Array expr = ((800+{})-800/2)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/B6v45 on line 28
Process exited with code 255.