Why exactly is eval evil?

前端 未结 12 1677
没有蜡笔的小新
没有蜡笔的小新 2020-11-22 09:51

I know that Lisp and Scheme programmers usually say that eval should be avoided unless strictly necessary. I’ve seen the same recommendation for several program

12条回答
  •  深忆病人
    2020-11-22 10:13

    Eval is just unsecure. For example you have following code:

    eval('
    hello('.$_GET['user'].');
    ');
    

    Now user comes to your site and enters url http://example.com/file.php?user=);$is_admin=true;echo(

    Then the resulting code would be:

    hello();$is_admin=true;echo();
    

提交回复
热议问题