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'))
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)
解决方案
$version = curl_version();
$ssl_supported= ($version['features'] & CURL_VERSION_SSL);
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.
Possible constants are:
CURL_VERSION_IPV6 (integer)
CURL_VERSION_KERBEROS4 (integer)
CURL_VERSION_SSL (integer)
CURL_VERSION_LIBZ (integer)