Login   Register  
PHP Classes
elePHPant
Icontem

File: main.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Alex Dan  >  Expressions  >  main.php  >  Download  
File: main.php
Role: Example script
Content type: text/plain
Description: Expression Example script
Class: Expressions
Parse, convert and evaluate math expressions
Author: By
Last change:
Date: 2012-07-08 02:55
Size: 561 bytes
 

Contents

Class file image Download
<?php
error_reporting 
(E_ALL);
include 
'Config/load.php';

$evaluator Expression_Evaluator::getInstance();

$str '(10 + 20) + (1 + 3 * 2 / (1+1))';
$strPostfix $evaluator->getConvertor()->strInfixToStrPostfix($str);
echo (
"\n".$str."\n");
echo (
"\n".$strPostfix."\n");
echo(
$evaluator->evaluateStrPostfix($strPostfix));
echo(
' === ');
eval(
'$x = '.$str.';');
echo (
$x."");
$expressionTree $evaluator->getConvertor()->strInfixToExpressionTree($str);
echo(
' === ');
echo (
$evaluator->evaluateExpressionTree($expressionTree));
echo (
"\n");