Latest web development tutorials

PHP curl_version函數

PHP curl_version函數

PHP Calendar 參考手冊 PHP cURL參考手冊

(PHP 5 >= 5.5.0)

curl_version — 獲取cURL版本信息。


說明

array curl_version ([ int $age = CURLVERSION_NOW ] )

返回關於cURL的版本信息。


參數

age


返回值

返回一個相關的數組包含如下元素:

Indice 值描述
version_number cURL 24位版本號
version cURL 版本號,字符串形式
ssl_version_number OpenSSL 24 位版本號
ssl_version OpenSSL 版本號,字符串形式
libz_version zlib 版本號,字符串形式
host 關於編譯cURL主機的信息
age
features 一個CURL_VERSION_XXX常量的位掩碼
protocols 一個cURL支持的協議名字的數組

實例

這個範例將會檢查當前cURL版本使用curl_version()返回的'features'位掩碼中哪些特性是可用的。

<?php
// 获取cURL版本数组
$version = curl_version();

// 在cURL编译版本中使用位域来检查某些特性
$bitfields = Array(
            'CURL_VERSION_IPV6', 
            'CURL_VERSION_KERBEROS4', 
            'CURL_VERSION_SSL', 
            'CURL_VERSION_LIBZ'
            );


foreach($bitfields as $feature)
{
    echo $feature . ($version['features'] & constant($feature) ? ' matches' : ' does not match');
    echo PHP_EOL;
}
?>

PHP Calendar 參考手冊 PHP cURL參考手冊