本文整理汇总了PHP中Math::calculate方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::calculate方法的具体用法?PHP Math::calculate怎么用?PHP Math::calculate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::calculate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: calculate
public function calculate( ) {
$this->initializeCalculator( );
if( ! empty($_POST['hasSubmit']) ) {
$leftOperand = (isset($_POST['leftOperand']) ? (int)$_POST['leftOperand'] : null );
$rightOperand = (isset($_POST['rightOperand']) ? (int)$_POST['rightOperand'] : null );
$firstOperator = (isset($_POST['firstOperator']) ? $_POST['firstOperator'] : null );
$secondOperator = (isset($_POST['secondOperator']) ? $_POST['secondOperator'] : null );
if( $secondOperator != '=' ) {
$this->registry->template->firstOperator = $secondOperator;
}
$calculator = new Math( );
$calculator->setFirstOperand($leftOperand);
$calculator->setSecondOperand($rightOperand);
$calculator->setFirstOperator($firstOperator);
$calculator->setSecondOperator($secondOperator);
$this->registry->template->leftOperand = $calculator->calculate();
}
$this->registry->template->show('math_index');
}
示例2: calculateValue
protected function calculateValue()
{
if (strlen($this->parsed) > 1 && $this->parsed[0] == '=') {
$expr = substr($this->parsed, 1);
$subcell = new SpreadSheetCell($this->connection, $this->sheetid, $expr, $this->prefix, $this->db_type);
if ($subcell->isIncorrect() === false) {
$expr = $subcell->getCalculatedValue();
} else {
$expr = $this->replaceCells($expr);
$math = new Math();
$expr = $math->calculate($expr);
}
$this->calc = $expr;
} else {
$this->calc = $this->parsed;
}
}