如何检查curl是否支持ssl? [英] How to check if curl has support for ssl?
问题描述
如何检查php curl是否使用ssl编译并支持ssl?
我的意思是,一个简单的检查curl是否可用是:
How can I check if php curl was compiled with ssl and has support for ssl? I mean, a simple check to see if curl is available would be:
if(extension_loaded('curl'))
if(extension_loaded('curl'))
但是如何检查curl是否也支持ssl?我需要这个检查,因为ssl支持需要使用基于oauth2的API,我需要一些方法快速检查客户端的php是否能够实际使用它(和失败)之前oauth2
but how do I check if curl also has support for ssl? I need this check because ssl support is needed to using oauth2 - based API and I need some way to quickly check if client's php is able to the oauth2 before actually using it (and failing)
推荐答案
请参阅 http: //www.php.net/manual/en/function.curl-version.php
$version = curl_version();
$ssl_supported= ($version['features'] & CURL_VERSION_SSL);
在$ version ['features']中有一个特征位掩码。
In $version['features'] you have a features bitmask. Through an and operation between this bitmask and the proper constant you can check if a feture is enabled.
可能的常数是:
CURL_VERSION_IPV6(整数)
CURL_VERSION_IPV6 (integer)
CURL_VERSION_KERBEROS4(整数)
CURL_VERSION_KERBEROS4 (integer)
CURL_VERSION_SSL(整数)
CURL_VERSION_SSL (integer)
CURL_VERSION_LIBZ(整数)
CURL_VERSION_LIBZ (integer)
这篇关于如何检查curl是否支持ssl?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!