Skip to content

Expression Parser

Compare
Choose a tag to compare
@danhunsaker danhunsaker released this 22 Feb 21:16
· 10 commits to master since this release

BC::math has a new feature, an expression parser, which allows you to use expression syntax instead of function calls to perform whatever operations you require. That means instead of writing:

BC::add(BC::add(BC::mul($a, BC::pow($x, 2)), BC::mul($b, $x)), $c);

you can write:

BC::parse("{$a} * {$x} ^ 2 + {$b} * {$x} + {$c}");

or even:

BC::parse('{a} * {x} ^ 2 + {b} * {x} + {c}', compact('a', 'b', 'c', 'x'));

More information about this feature is available in the README.