我正在使用以下代码
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)
〜谢谢
我正在尝试检测在从命令行运行的脚本中是否使用 PHP 安装了curl。我尝试了以下方法:
if(@function_exists('curl_version')){
...
}
Run Code Online (Sandbox Code Playgroud)
和
error_reporting(E_ERROR);
ini_set('display_errors', '0');
if(is_callable('curl_init')){
...
}
Run Code Online (Sandbox Code Playgroud)
但在这两种情况下我都会收到以下消息:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-zts-20121212/curl.so' - /usr/local/lib/php/extensions/no-debug-zts-20121212/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)
我更愿意隐藏错误消息,但似乎 @ 和 error_reporting 不起作用。有其他方法来抑制此消息吗?