Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to check if phpinfo() exists AND is readable? WordPress


Within my code, I use the following to check if phpinfo is available:

// Try phpinfo()
/*if (function_exists('phpinfo'))

$access_details['domain']=$this->scrape_phpinfo($list, 'HTTP_HOST');
$access_details['ip']=$this->scrape_phpinfo($list, 'SERVER_ADDR');
$access_details['directory']=$this->scrape_phpinfo($list, 'SCRIPT_FILENAME');
$access_details['server_hostname']=$this->scrape_phpinfo($list, 'System');
$access_details['server_ip'][email protected]($access_details['server_hostname']);

I now discovered a problem on hosts, where phpinfo() exists but is not readable (displaying "Warning: phpinfo() has been disabled for security reasons in....") when trying to call the function. With the code above, the script breaks the whole site :-/

Is there another way to check if phpinfo() exists AND can be accessed too? Like
if (function_exists('phpinfo') && phpinfo == readable) ;-)

Thanks for any help!

Update 1:
according to my provider, phpinfo is blocked by Firewall, IDS and suhosin :-/

Answers (3)


Dbranes answers:

You might check this one:

function is_disabled($function) {
return in_array($function, $disabled_functions);

[[LINK href=""]]source[[/LINK]]

Robert Seyfriedsberger comments:

thats an approach, but as I see from $disabled_functions=explode(',',ini_get('disable_functions')); - phpinfo() is not in the list of disabled functions. Is there another way to check this? Like if (phpinfo('xxx') == NULL)...

Dbranes comments:

When I test this on a host with some disabled php functions:

echo ini_get('disable_functions');

I get this output:

show_source, system, shell_exec, passthru, exec, phpinfo, shell, symlink, popen, proc_open

When I modify the above code, to remove spaces:

function is_disabled($function) {
$disabled_functions=explode(',',str_replace(" ","",ini_get('disable_functions')));
return in_array($function, $disabled_functions);


echo is_disabled("phpinfo")?"is disabled":"is enabled";

gives the output:

is disabled

So if this function works for you, then you could use it in your code like this:





Navjot Singh answers:



Christianto answers:

deleted -- not working