问题
I have an app that is failing on the install. The vendor says I probably have ini_set() disabled. How can I check this?
回答1:
I did some research on this, and it turns out that sometimes ini_set will not return FALSE, but an empty string. This is mentioned in the URL pointed out by gabriel1836. The best way to check if it works is to first check the disable_functions flag in php.ini to see if it is disabled, and then (if it is not disabled), change a value with it, and echo phpinfo() immediately after. If the value is changed under the local column, then you know ini_set works.
回答2:
You might want to take a look at the CHANGEABLE directives in php.ini: http://us3.php.net/manual/en/ini.php#ini.list
In regard to verify whether an ini_set function worked, you can check the return value to make certain that it worked: http://us3.php.net/manual/en/function.ini-set.php
The code would look something like this:
<?php
if(ini_set('error_reporting', 'ALL') === false)
{
// Perform failure handling logic
}
?>
回答3:
You could check the disable_functions
setting in your php.ini file. That's pretty much the only thing I can think of. I doubt it would be set, though, unless you're running on shared hosting or something like that.
You might also want to check if the relevant setting is specified using php_admin_flag
or php_admin_value
in your Apache config, as those will effectively "lock" the setting and keep ini_set()
from changing it.
来源:https://stackoverflow.com/questions/247152/how-do-i-check-if-ini-set-is-enabled-either-in-the-global-php-ini-or-in-my-php