2017 © Pedro PelĂĄez
 

php-class eval-math

Safely evaluate mathematical expressions

image

israelfl/eval-math

Safely evaluate mathematical expressions

  • Wednesday, January 24, 2018
  • by israelfl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

eval-math

Composer/Packagist version of EvalMath by Miles Kaufman Copyright (C) 2005 Miles Kaufmann http://www.twmagic.com/ Version 1.0, (*1)

Taken from http://www.phpclasses.org/browse/file/11680.html, cred to Miles Kaufmann, (*2)

NAME

EvalMath - safely evaluate math expressions

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

To use it just require this extension in your composer.json file:, (*3)

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

Or just:, (*4)

composer require israelfl/eval-math

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

$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., (*5)

$m->e($expr);

A synonym for $m->evaluate()., (*6)

$m->vars();

Returns an associative array of all user-defined variables and values., (*7)

$m->funcs();

Returns an array of all user-defined functions., (*8)

PARAMETERS

$m->suppress_errors;

Set to true to turn off warnings when evaluating expressions, (*9)

$m->last_error;

If the last evaluation failed, contains a string describing the error. (Useful when suppress_errors is on)., (*10)

The Versions

24/01 2018

dev-master

9999999-dev

Safely evaluate mathematical expressions

  Sources   Download

MIT MIT License

The Requires

  • php >=5.3

 

The Development Requires

by Israel FalcĂłn

php math class eval expression

28/03 2017

0.0.3

0.0.3.0

Safely evaluate mathematical expressions

  Sources   Download

MIT License

The Requires

  • php >=5.3

 

The Development Requires

by Israel FalcĂłn

php math class eval expression

28/03 2017

0.0.2

0.0.2.0

Safely evaluate mathematical expressions

  Sources   Download

MIT License

The Requires

  • php >=5.3

 

The Development Requires

by Israel FalcĂłn

php math class eval expression

28/03 2017

0.0.1

0.0.1.0

Safely evaluate mathematical expressions

  Sources   Download

MIT License

The Requires

  • php >=5.3

 

The Development Requires

by Israel FalcĂłn

php math class eval expression