如何检查allow_url_fopen是否启用

Reh*_*hmy 25 php

我正在使用以下代码

echo 'file_get_contents : ', ini_get('allow_url_fopen') ? 'Enabled' : 'Disabled';
Run Code Online (Sandbox Code Playgroud)

这可以启用或禁用它

但我想把函数名称作为函数 _isgetcontents

然后我可以将其称为跟随我的网站代码中的任何位置

if (_isgetcontents()){
echo "this is enabled"; // will do an action
}else{
echo "this is disabled"; // will do another action
}
Run Code Online (Sandbox Code Playgroud)

〜谢谢

Mar*_*ski 59

使用ini_get()获取某些配置参数的值:

if( ini_get('allow_url_fopen') ) {
   // lucky me...
} 
Run Code Online (Sandbox Code Playgroud)