evaluate math expressions

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
$Expression = "(6-2)*4";

should return 16 , which_php_Math_fxn ($Expression) returns 16

any function to evaluate math expressions in php?
 
i believe you may use eval to evaluate it as a php code:

something like:

Code:
<?php
$expr = "(6-2)*4";
$expr = '$return = '.$expr.';';
eval($expr);
echo $return;
?>
 
Back
Top