web-technologies / yii2-calculator
yii2的计算器扩展
1.1.1
2019-07-03 08:08 UTC
Requires
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2024-09-29 05:28:36 UTC
README
yii2的计算器扩展
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一:
php composer.phar require web-technologies/yii2-calculator "*"
或者
"web-technologies/yii2-calculator": "*"
将其添加到您的composer.json文件的require部分。
配置
在配置文件中
/config/web.php
添加数学组件
'components' => array(
...
'math' => array(
'class' => 'webtechnologies\calculator\Math',
//'handlerClass' => 'namespace/to/customHandlerClass', //optional parameter
),
)
用法
扩展安装完成后,您只需在代码中通过
<?=Yii::$app->math->expr('( 5 + (5 * 6) - 3 + 4 * 4 ^ 6 + ( -3 * -5 * 4 + ( 3 / 34 + 1 * 3 + 6 - 3 + ( 4 / 2 ) ) ) ) * -1')?> //output: -16484.088235294