[Phpwm] Fnuction to calculate a formula

pete graham petegraham1 at gmail.com
Tue Dec 4 10:30:10 GMT 2007


As we are all justifiably paranoid about users pumping malicious input
into eval() wouldn't it be best/safest to calculate these relatively
simple sums using JavaScript instead?

Pete

On 04/12/2007, Phil Beynon <phil at infolinkelectronics.co.uk> wrote:
> >
> >
> > Hello,
> > I am on the hunt for a PHP 5 function that will calculate a given formula.
> > For example:
> >
> > $formula="2+2";
> > $result=calculate_formula($formula);
> > echo "$formula = $result";
> >
> > Would reult in:
> >
> > 2+2 = 4
> >
> > Anyone got any ideas?
> > Cheers,
> > Colin
> >
>
>
> Colin,
> are the users entering the actual formula here?
>
> eval() is OK if internal but it needs to be ringfenced if any user input can
> be directed against it.
>
> Phil
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.16.13/1165 - Release Date: 02/12/2007
> 20:34
>
> _______________________________________________
> Phpwm mailing list
> Phpwm at mailman.lug.org.uk
> https://mailman.lug.org.uk/mailman/listinfo/phpwm
>
>



More information about the Phpwm mailing list