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

ActivePhp-class[Utility &amp; Helpers](/categories/utility)

israelfl/eval-math
==================

Safely evaluate mathematical expressions

0.0.3(9y ago)093MIT LicensePHPPHP &gt;=5.3

Since Mar 28Pushed 8y ago1 watchersCompare

[ Source](https://github.com/israelfl/eval-math)[ Packagist](https://packagist.org/packages/israelfl/eval-math)[ RSS](/packages/israelfl-eval-math/feed)WikiDiscussions master Synced 4w ago

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

eval-math
=========

[](#eval-math)

Composer/Packagist version of EvalMath by Miles Kaufman Copyright (C) 2005 Miles Kaufmann Version 1.0

Taken from , cred to Miles Kaufmann

NAME
----

[](#name)

```
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!

```

INSTALLATION
------------

[](#installation)

To use it just require this extension in your `composer.json` file:

```
"israelfl/eval-math": "0.0.1",

```

Or just:

```
composer require israelfl/eval-math

```

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-&gt;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

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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 ~0 days

Total

3

Last Release

3381d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4442168?v=4)[Israel Falcón Leal](/maintainers/israelfl)[@israelfl](https://github.com/israelfl)

---

Tags

phpclassmathexpressioneval

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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