PHP code example of oat-sa / lib-beeme
1. Go to this page and download the library: Download oat-sa/lib-beeme library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
oat-sa / lib-beeme example snippets
$parser = new \oat\beeme\Parser();
$expression = '1 + 2 * 3 * ( 7 * 8 ) - ( 45 - 10 )';
$result = $parser->evaluate($expression);
echo $result; // 302.000000
$parser = new \oat\beeme\Parser();
$expression = '3 + x';
$result = $parser->evaluate(
$expression,
['x' => 3]
);
echo $result; // 6.000000
$expression = '1 + abs(x)';
$result = $parser->evaluate(
$expression,
['x' => -10]
);
echo $result; // 11.000000