Check if ini_get() is disabled

Is it possible to check if ini_get() is disabled? I don’t expect ini_get(‘disable_functions’) would work. :slight_smile:

You can use function_exists().

Are you sure?

Testing myself for function_exists(‘system’) (a disabled function on my server) I get TRUE; however, get_defined_functions() includes system(). Odd.

A note further down the page there states, “function_exists will return false for functions disabled with the disable_functions ini directive.” I guess that’s definitive.

True, I guess this will not work for explicitly disabled functions (vs. functions belonging to un-installed modules where it will work). You could try a try…catch block, although I’m not sure this is the best method.

Extremely nasty, but the following works (just tested it)


$x=@ini_get('upload_max_filesize') or $x='ThisIsMessedUpYo';

$ini_get_enabled=($x!=='ThisIsMessedUpYo');
var_dump($ini_get_enabled);

It doesn’t work if for some reason “ThisIsMessedUpYo” will be set as a value in php.ini, but I highly doubt that will ever happen (:

Actually, that works fine.


$funcs = array_map('trim', explode(',', ini_get('disable_functions')));

$funcs now lists functions mentioned in disable_functions :slight_smile:

As you’ve already noted, if ini_get() is specified within the disable_functions ini option then function_exists('ini_get') will return FALSE and trying to call ini_get(…) will raise an E_WARNING (Warning: ini_get() has been disabled for security reasons in…) and return NULL.

Note to self: pay more attention when suggestion clever bits of code!