zhuravljov/calc

Library for the calculation of simple math expressions

Details

Homepage

Source

Issues

74

0

3

2

0

1.0.1 2015-05-08 14:27 UTC

This package is auto-updated.

Last update: 2020-07-18 16:30:39 UTC

Library for the calculation of simple math expressions without using `eval()`.

Installation

The preferred way to install this extension is through composer.

Either run

``````\$ composer require zhuravljov/calc
``````

``````"zhuravljov/calc": "*"
``````

to the `require` section of your `composer.json` file.

Usage

```\$calculator = new \zhuravljov\calc\Calculator();
\$calculator->calc('2 + 2 * 2'); // 6
\$calculator->calc('(2 + 2) * 2'); // 8
\$calculator->calc('(2 + 2'); // CalcException```

Available operations `+`, `-`, `*` and `/`.