Dynamic logical expression parsing/evaluation in PHP?

前端 未结 6 493
隐瞒了意图╮
隐瞒了意图╮ 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:29

    You can try adapting my Evaluator class (https://github.com/djfm/Evaluator), it does arithmetic expressions (for now) and you can use variables too. All the major PHP operators are implemented.

提交回复
热议问题