Prepare lib to be a native class
This commit is contained in:
parent
c50b772b11
commit
73273f68b3
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
================================================================================
|
||||
|
||||
@ -92,7 +91,7 @@ class EvalMath {
|
||||
var $last_error = null;
|
||||
var $last_error_code = null;
|
||||
|
||||
var $v = array('e'=>2.71,'pi'=>3.14); // variables (and constants)
|
||||
var $v = array('e'=>2.71,'pi'=>3.14159); // variables (and constants)
|
||||
var $f = array(); // user-defined functions
|
||||
var $vb = array('e', 'pi'); // constants
|
||||
var $fb = array( // built-in functions
|
||||
@ -101,7 +100,10 @@ class EvalMath {
|
||||
'tan','tanh','arctan','atan','arctanh','atanh',
|
||||
'sqrt','abs','ln','log');
|
||||
|
||||
function EvalMath() {
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
// make the variables a little more accurate
|
||||
$this->v['pi'] = pi();
|
||||
$this->v['e'] = exp(1);
|
||||
@ -172,7 +174,7 @@ class EvalMath {
|
||||
function nfx($expr) {
|
||||
|
||||
$index = 0;
|
||||
$stack = new EvalMathStack;
|
||||
$stack = new EvalMathStack();
|
||||
$output = array(); // postfix form of expression, to be passed to pfx()
|
||||
$expr = trim(strtolower($expr));
|
||||
|
||||
@ -299,7 +301,7 @@ class EvalMath {
|
||||
|
||||
if ($tokens == false) return false;
|
||||
|
||||
$stack = new EvalMathStack;
|
||||
$stack = new EvalMathStack();
|
||||
|
||||
foreach ($tokens as $token) { // nice and easy
|
||||
// if the token is a binary operator, pop two values off the stack, do the operation, and push the result back on
|
||||
@ -365,7 +367,9 @@ class EvalMath {
|
||||
}
|
||||
}
|
||||
|
||||
// for internal use
|
||||
/**
|
||||
* Class for internal use
|
||||
*/
|
||||
class EvalMathStack {
|
||||
|
||||
var $stack = array();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user