How to parse a string of boolean logic in PHP
- by TheOddLinguist
I'm building a PHP class with a private member function that returns a string value such as:
'true && true || false'
to a public member function. (This string is the result of some regex matching and property lookups.) What I'd like to do is have PHP parse the returned logic and have the aforementioned public function return whether the boolean result of the parsed logic is true or false.
I tried eval(), but I get no output at all. I tried typecasting the boolean returns...but there's no way to typecast operators...hehe Any ideas? (Let me know if you need more information.)