Exemple #1
0
 /**
  * Solve
  *
  * This function is called by the user to solve an equation within the parser system
  * No internal functions or added advanced functions should ever call this. Sets
  * the internal $infix variable for use in thrown exceptions. The variable array must
  * be in the format of 'variable' => value. If variable array is scalar (ie 5), all
  * variables will be replaced with it.
  *
  * @param $equation String Equation to Solve
  * @param Array|Double $values variable values
  * @return Float Answer to the equation
  */
 public static function solve($equation, $values = null)
 {
     if (is_array($equation)) {
         return self::solvePF($equation);
     } else {
         self::$inFix = $equation;
         return self::solveIF($equation, $values);
     }
 }
Exemple #2
0
 /**
  * Construct method
  *
  * Will initiate the class.  If variable given, will assign to
  * internal variable to solve with this::solveIF() without needing
  * additional input.  Initializing with a variable is not suggested.
  *
  * @see Parser::solveIF()
  * @param String $inFix Standard format equation
  */
 public function __construct($inFix = null)
 {
     if (defined('DEBUG') && DEBUG) {
         self::$debug = true;
     }
     $this->inFix = isset($inFix) ? $inFix : null;
     $this->postFix = array();
 }