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

ActivePhp-class

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 2mo 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 27% 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

3335d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/803bbb75244961665da9da7cc1eb8a8b929c8c293bd9153798c2be118104bb84?d=identicon)[israelfl](/maintainers/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)
```

###  Alternatives

[madorin/matex

PHP Mathematical expression parser and evaluator

1161.2M1](/packages/madorin-matex)[denissimon/formula-parser

Parsing and evaluating mathematical formulas given as strings.

81306.8k3](/packages/denissimon-formula-parser)[stefangabos/zebra_database

An advanced, compact and lightweight MySQL database wrapper library, built around PHP's MySQLi extension.

11812.0k](/packages/stefangabos-zebra-database)[leonelquinteros/php-toml

PHP parser for TOML language ( https://github.com/toml-lang/toml )

266.7k](/packages/leonelquinteros-php-toml)[mathematicator-core/tokenizer

Math Tokenizer

104.9k6](/packages/mathematicator-core-tokenizer)

PHPackages © 2026

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