如何在不进入 php.ini 文件的情况下禁用 eval 函数?

发布于 2024-08-14 05:50:26 字数 304 浏览 2 评论 0原文

有没有办法禁用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

酒中人 2024-08-21 05:50:26

它不起作用,因为 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:

Note: Because this is a language construct and not a function,
it cannot be called using variable functions 
A君 2024-08-21 05:50:26

如果这是使用 apache 的 mod_php (不是 CGI),.htaccess 就可以工作。除此之外...运气不好。

if this is mod_php (not CGI) with apache, .htaccess will work. other than that... bad luck.

涙—继续流 2024-08-21 05:50:26

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.

酸甜透明夹心 2024-08-21 05:50:26

我想您可以使用一个不执行任何操作的新函数来调用 override_function 。 (要求 APD)

I guess you could call override_function with a new function which does nothing. (req APD)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文