aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBruce Wells <brucekwells@gmail.com>2020-07-27 19:25:59 +0300
committerBruce Wells <brucekwells@gmail.com>2020-09-16 04:14:44 +0300
commit8a2cae984f77ed55195bed071b12a165fa532561 (patch)
treef91391945ab9eea944a785209d6db1698e1529cc /README.md
parent92d1a4524b5b2c7b4fc778e99815a49d227fc5ef (diff)
Better setVar error message (#70)
Additional unit tests Readme update
Diffstat (limited to 'README.md')
-rw-r--r--README.md6
1 files changed, 4 insertions, 2 deletions
diff --git a/README.md b/README.md
index 69651d5..f88e5e3 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# MathExecutor [![Tests](https://github.com/neonxp/MathExecutor/workflows/Tests/badge.svg)](https://github.com/neonxp/MathExecutor/actions?query=workflow%3ATests) [![Latest Packagist release](https://img.shields.io/packagist/v/nxp/math-executor.svg)](https://packagist.org/packages/nxp/math-executor)
+# MathExecutor [![Tests](https://github.com/neonxp/MathExecutor/workflows/Tests/badge.svg)](https://github.com/neonxp/MathExecutor/actions?query=workflow%3ATests)
# A simple and extensible math expressions calculator
@@ -115,6 +115,8 @@ You can think of the **if** function as prototyped like:
function if($condition, $returnIfTrue, $returnIfFalse)
```
## Variables:
+Variables can be prefixed with the dollar sign ($) for PHP compatibility, but is not required.
+
Default variables:
```
@@ -127,7 +129,7 @@ You can add your own variables to executor:
```php
$executor->setVar('var1', 0.15)->setVar('var2', 0.22);
-echo $executor->execute("$var1 + $var2");
+echo $executor->execute("$var1 + var2");
```
You can dynamically define variables at run time. If a variable has a high computation cost, but might not be used, then you can define an undefined variable handler. It will only get called when the variable is used, rather than having to always set it initially.