zhuravljov / calc
Library for the calculation of simple math expressions
Installs: 92
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/zhuravljov/calc
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2025-10-19 03:36:17 UTC
README
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
or add
"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 /.