php 如何检查是否启用了allow_url_fopen

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13433660/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 05:24:58  来源:igfitidea点击:

How to check if allow_url_fopen is enabled or not

php

提问by Reham Fahmy

I'm using the following code

我正在使用以下代码

echo 'file_get_contents : ', ini_get('allow_url_fopen') ? 'Enabled' : 'Disabled';

this can get it enabled or disabled

这可以启用或禁用它

but I would like to make as function say function name is _isgetcontents

但我想作为函数说函数名称是 _isgetcontents

then I can call it as following any where in my website code

然后我可以在我的网站代码中的任何位置调用它

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

回答by Marcin Orlowski

Use ini_get()to get the value of certain configuration parameters:

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

if( ini_get('allow_url_fopen') ) {
   // lucky me...
} 

回答by Faiyaz Alam

you can also use this method

你也可以用这个方法

phpinfo()

phpinfo()

to check various configurations.

检查各种配置。