PHPackages                             z/math-executor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. z/math-executor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

z/math-executor
===============

Simple math expressions calculator - extension of http://github.com/NeonXP/MathExecutor

24.5k1[1 issues](https://github.com/zRosenthal/math-executor/issues)PHP

Since Oct 10Pushed 8y ago2 watchersCompare

[ Source](https://github.com/zRosenthal/math-executor)[ Packagist](https://packagist.org/packages/z/math-executor)[ RSS](/packages/z-math-executor/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

Simple math expressions calculator

Install via Composer
--------------------

[](#install-via-composer)

All instructions to install here:

Sample usage:
-------------

[](#sample-usage)

```
require "vendor/autoload.php";

$calculator = new \Z\MathExecutor();

print $calculator->execute("1 + 2 * (2 - (4+10))^2 + sin(10)");
```

Functions:
----------

[](#functions)

Default functions:

- sin
- cos
- tn
- asin
- acos
- atn
- min
- max
- avg

Add custom function to executor:

```
$executor->addFunction('abs', function($arg) {
    return abs($arg);
}, 1);
```

Operators:
----------

[](#operators)

Default operators: `+ - * / ^`

Add custom operator to executor:

MyNamespace/ModulusToken.php:

```
