How to disable eval function without going to php.ini file?
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.
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
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 allows you to disable eval in php7 as well as php5. Suhosin is only stable in php5.
I guess you could call override_function
with a new function which does nothing. (req APD)
精彩评论