aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorBruce Wells <brucekwells@gmail.com>2020-07-27 19:25:59 +0300
committerGitHub <noreply@github.com>2020-07-27 19:25:59 +0300
commit44d72cc252974ac36cc138591aac785022760a50 (patch)
treef91391945ab9eea944a785209d6db1698e1529cc /README.md
parentb38893d672f479314e8b9f254457b8b9755c781f (diff)
Better setVar error message (#70)V2.1.1
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.