|
Posted by werner on 01/20/06 09:28
Hi!
I don't want to use eval() in order to parse a user-supplied formula.
What alternatives do I have? PHP has no standard functionality for
tokenizing or parsing expressions in this regard.
Here is a simple example: The user supplies the following formula in
string format,
"a = (6+10)/4",
and the script needs to find out what the value of 'a' is.
How can I go about it without using eval(), since using eval in this
case could be very risky! (The user can supply *any* expression, as
there is no function that can determine the meaning of the string as an
expression).
Thank you for taking the time t read my question.
Navigation:
[Reply to this message]
|