如何在不进入 php.ini 文件的情况下禁用 eval 函数?
有没有办法禁用 eval 功能,而无需从 php.ini 文件中执行此操作。 我尝试过 ini_set 函数,但即使这样也不起作用。
基本上我希望我的框架用户决定是否应该通过配置文件启用此功能。如果他们说不,我应该能够使用代码禁用它,因为我无法转到安装我的框架的每个用户的服务器并使用 php.ini 文件禁用它。
正如我所说,没有转到 php.ini 文件,因此 ini 指令 disable_functions 不应发布在答案中。
请帮忙。
Is there a way to disable eval function without doing so from php.ini file.
I have tried ini_set function but even that doesn't work.
Basically I want my framework users to decide whether this function should be enabled or not through a config file. If they say no, i should be able to disable it using code as i can't go to server of each users where my framework is installed and disabling it using php.ini file.
As i said without goint to php.ini file, so ini directive disable_functions should not be posted in answers.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它不起作用,因为 eval() 不是一个函数 - 它是一种语言构造。您可以使用 PHP 保护系统 suhosin 禁用它。这是我所知道的唯一方法。
来自 PHP.net:
It won't work, because eval() is not a function - it's a language construct. You can disable it with suhosin, a protection system for PHP. That's the only way I know of.
From PHP.net:
如果这是使用 apache 的 mod_php (不是 CGI),.htaccess 就可以工作。除此之外...运气不好。
if this is mod_php (not CGI) with apache, .htaccess will work. other than that... bad luck.
https://github.com/mk-j/PHP_diseval_extension 允许您在 php7 中禁用 eval以及 php5。 Suhosin 仅在 php5 中稳定。
https://github.com/mk-j/PHP_diseval_extension allows you to disable eval in php7 as well as php5. Suhosin is only stable in php5.
我想您可以使用一个不执行任何操作的新函数来调用
override_function
。 (要求 APD)I guess you could call
override_function
with a new function which does nothing. (req APD)