how to handle parse error for eval function in php

后端 未结 3 689
陌清茗
陌清茗 2021-01-19 09:25

I\'m trying to use the eval function for php. but I\'m stuck in handling the parse error. like considering if I have edge cases like 1.. or 1++ if gives me parse error:synta

3条回答
  •  旧时难觅i
    2021-01-19 10:24

    From the manual:

    If there is a parse error in the evaluated code, eval() returns FALSE and execution of the following code continues normally. It is not possible to catch a parse error in eval() using set_error_handler().

    But as you won't be calling eval on arbitrary code (right?), this shouldn't be a problem.

提交回复
热议问题