是否可以从数据库中加载执行PHP代码?

ope*_*rog -1 php

如果我在数据库中有PHP代码,我可以在PHP中以某种方式"包含"并执行它吗?好吧,我确定我可以写出一个包含该内容的文件并且只包含该文件,但是PHP可能有类似于JavaScript的eval()?

Pek*_*ica 5

是的,PHP也有eval(),但是使用它被认为是非常糟糕的做法.

这个问题很好地讨论了主要观点,没有完全谴责它.

Most often, if eval() comes up, it is worth taking a hard look at the program you're building: There is probably a better way to do it. For example, if you want to fill data values into HTML code that is stored in a data base, a templating engine of some sort might be a better idea.