function _calc($params) { $user = $params['user']; $channel = $params['channel']; $query = $params['query']; $query = html_entity_decode($query); $calc = new Calc($query); echo htmlspecialchars($expression) . "\n"; echo $calc->infix() . " = " . $calc->calc() . "\n"; $output = Utils::cmdout($params); $output .= $calc->infix() . " = " . $calc->calc(); Status::create()->data($output)->user_id($user->id)->channel($channel)->insert(); return true; }
function __construct($v) { if (is_array($v)) { $this->values = $v; $this->saved_values = $this->values; $this->label = '[' . implode(', ', $v) . ']'; } else { $this->label = $v; preg_match('%^(?P<multiple>\\d*)\\[(?P<set>[^\\]]+)\\]$%i', $v, $matches); $v = $matches['set']; $values = explode(',', $v); for ($z = 0; $z < max(1, intval($matches['multiple'])); $z++) { foreach ($values as $v) { $this->values[] = $v; } } $this->saved_values = $this->values; foreach ($this->values as $k => $v) { $calc = new Calc($v); $this->values[$k] = $calc->calc(); } foreach ($this->values as $k => $value) { $calc = new Calc($value); $this->values[$k] = $calc->calc(); } } }
public function calc($expression) { return Calc::calc($expression); }
?> "> <input type="submit" value="Calc"> </form> <style type="text/css"> s { color: #999; } .true { color: green; font-weight: bold; } .false { color: #999; } </style> <pre><?php include 'calc.php'; $expression = $_GET['expression']; $calc = new Calc($expression); echo htmlspecialchars($expression) . "\n"; echo $calc->infix(); echo " => "; echo $calc->calc() . "\n"; ?> </pre> </body> </html>