发布日期:2018-03-26
如何检查curl是否启用或禁用+ 查看更多
如何检查curl是否启用或禁用
+ 查看更多
发布日期:2018-03-10 15:22
分类:PHP
浏览次数:369
我在使用如下代码:
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' : 'Disabled';这可以让它启用或禁用。但我想做为函数,函数名是_iscurl。然后我可以在以下任何地方调用它作为我的网站代码。
if (_iscurl()){ echo "this is enabled"; // will do an action }else{ echo "this is disabled"; // will do another action }
和我以前的问题类似:检查allow_url_fopen是否启用。
回答
只需从函数返回function_exists检查的结果。
function _isCurl(){ return function_exists('curl_version'); }