Dynamic logical expression parsing/evaluation in PHP?

前端 未结 6 494
隐瞒了意图╮
隐瞒了意图╮ 2021-01-11 14:10

I have a need to evaluate user-defined logical expressions of arbitrary complexity on some PHP pages. Assuming that form fields are the primary variables, it would need to:

6条回答
  •  太阳男子
    2021-01-11 14:47

    Take a look at my infix to postfix example I think you could port it to PHP with relative ease. It only uses an array and some switches. No trees. A stack is only needed to run the postfix result.

提交回复
热议问题