On Tue, Aug 12, 2008 at 9:30 AM, Platonides
<Platonides(a)gmail.com> wrote:
Instead of writing a math parser in php, what
about using php own
ability to cope with mathematical expressions via eval()?
It would obviously need strong checkings to avoid opening holes, but if
all the characters match [0-9]+-*/%() it should be safe to pass to the
php parser.
Maybe . . . what does PHP do on division by zero? I admit that's the
only thing I can think of that would be a problem. (You should
probably allow . too, for a decimal point.)
There is much more funny errors that can be met:
square root of negative number
fractional powers of negative number
logarithm of negative number
arcus sinus of number <-1 or >1
And many more
AJF/WarX