相关疑难解决方法(0)

如何检查allow_url_fopen是否启用

我正在使用以下代码

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

25
推荐指数
1
解决办法
3万
查看次数

如何测试curl在PHP中是否可用且没有错误

我正在尝试检测在从命令行运行的脚本中是否使用 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 不起作用。有其他方法来抑制此消息吗?

php curl error-suppression suppress hide

1
推荐指数
1
解决办法
4714
查看次数

标签 统计

php ×2

curl ×1

error-suppression ×1

hide ×1

suppress ×1