What situations demand the use of eval() because there are no alternatives?

后端 未结 5 1698
小蘑菇
小蘑菇 2021-01-18 00:07

I know eval should be avoided in JavaScript for speed and security reasons. But in the case of PHP, rarely is security ever mentioned. More often, it\'s your pr

5条回答
  •  [愿得一人]
    2021-01-18 00:26

    i know eval should be avoided in javascript for speed and security reasons. but in the case of php, rarely is security ever mentioned. more often it's your program running slower than it should because of haphazard use of eval.

    eval is evil in php too.

    in what specific situations should you use eval() because there is no other way around it?

    First of all, we try to avoid it as much as possible, but if you do have to use that for executing some code, then you will have to go with that but as said it is evil, you use at your own risk.

    Bottom Line:

    Never allow at any rate, the user input to be run with eval. (Unless You Know What You Are Doing/Risking)

提交回复
热议问题