PHPackages                             webit/eval-math - 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. webit/eval-math

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

webit/eval-math
===============

EvalMath

1.0.2(1y ago)28838.7k↓12.3%174PHPPHP &gt;=5.3

Since May 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/dbojdo/eval-math)[ Packagist](https://packagist.org/packages/webit/eval-math)[ RSS](/packages/webit-eval-math/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (4)

Composer/Packagist version of EvalMath by Miles Kaufman Copyright (C) 2005 Miles Kaufmann NAME
-----------------------------------------------------------------------------------------------------------------------

[](#composerpackagist-version-of-evalmath-by-miles-kaufmancopyright-c-2005-miles-kaufmann-httpwwwtwmagiccomname)

```
EvalMath - safely evaluate math expressions

```

DESCRIPTION
-----------

[](#description)

```
Use the EvalMath class when you want to evaluate mathematical expressions
from untrusted sources.  You can define your own variables and functions,
which are stored in the object.  Try it, it's fun!

```

SYNOPSIS
--------

[](#synopsis)

```
`$m = new EvalMath;`

`// basic evaluation:`
`$result = $m->evaluate('2+2');`

`// supports: order of operation; parentheses; negation; built-in functions`
`$result = $m->evaluate('-8(5/2)^2*(1-sqrt(4))-8');`

`// create your own variables`
`$m->evaluate('a = e^(ln(pi))');`

`// or functions`
`$m->evaluate('f(x,y) = x^2 + y^2 - 2x*y + 1');`

`// and then use them`
`$result = $m->evaluate('3*f(42,a)');`

```

METHODS
-------

[](#methods)

```
`$m->evaluate($expr)`
    Evaluates the expression and returns the result.  If an error occurs,
    prints a warning and returns false.  If $expr is a function assignment,
    returns true on success.

`$m->e($expr)`
    A synonym for $m->evaluate().

`$m->vars()`
    Returns an associative array of all user-defined variables and values.

`$m->funcs()`
    Returns an array of all user-defined functions.

```

PARAMETERS
----------

[](#parameters)

```
`$m->suppress_errors`
    Set to true to turn off warnings when evaluating expressions

`$m->last_error`
    If the last evaluation failed, contains a string describing the error.
    (Useful when suppress_errors is on).

```

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance45

Moderate activity, may be stable

Popularity50

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1799 days

Total

3

Last Release

431d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a6cc50814a7b150c2a02d719d33c6e11040a6d0d010b2f986a24794edce7f52f?d=identicon)[dbojdo](/maintainers/dbojdo)

---

Top Contributors

[![dbojdo](https://avatars.githubusercontent.com/u/1272416?v=4)](https://github.com/dbojdo "dbojdo (6 commits)")[![dbojdo8x8](https://avatars.githubusercontent.com/u/76156710?v=4)](https://github.com/dbojdo8x8 "dbojdo8x8 (2 commits)")[![ngirardet-mob](https://avatars.githubusercontent.com/u/92201623?v=4)](https://github.com/ngirardet-mob "ngirardet-mob (1 commits)")[![tecem](https://avatars.githubusercontent.com/u/1611445?v=4)](https://github.com/tecem "tecem (1 commits)")

---

Tags

EvalMath

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/webit-eval-math/health.svg)

```
[![Health](https://phpackages.com/badges/webit-eval-math/health.svg)](https://phpackages.com/packages/webit-eval-math)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
