For a complex project I'm working on, I want administrators to be allowed to attach conditions to events using boolean expressions.
Example:
if (1 > 2 || (1 == 1 && 3 > 2)) [...]
The above would return TRUE.
eval()
seems like an easy solution, but I am well aware of the security risks it presents. Does PHP provide a way to evaluate expressions like the above without actually evaluating other arbitrary PHP code? Options would be something that only evaluates mathematical expressions, or perhaps an eval()
sanitizer that accepts a whitelist of functions.
Thanks for your help!