<?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;
//var_dump($token);
var_dump($id); vap_dump($text)
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.4.29
- Parse error: syntax error, unexpected 'if' (T_IF) in /in/Z8qPD on line 22
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected T_IF in /in/Z8qPD on line 22
Process exited with code 255.
preferences:
191.77 ms | 940 KiB | 67 Q