(PHP 4 >= 4.0.2, PHP 5, PHP 7, PHP 8)
curl_version — 取得 cURL 版本資訊
此函式沒有參數。
返回一個包含下列元素的關聯式陣列
鍵值 | 值的描述 |
---|---|
version_number | cURL 24 位元版本號 |
version | cURL 版本號,以字串表示 |
ssl_version_number | OpenSSL 24 位元版本號 |
ssl_version | OpenSSL 版本號,以字串表示 |
libz_version | zlib 版本號,以字串表示 |
host | 建置 cURL 之主機的相關資訊 |
age | |
features | CURL_VERSION_* 常數的位元遮罩 (bitmask) |
protocols | cURL 支援的協定名稱陣列 |
feature_list | 一個關聯式陣列,包含所有已知的 cURL 功能,以及它們是否被支援 (true ) 或不被支援 (false ) |
版本 | 說明 |
---|---|
8.4.0 |
新增了 features_list 。 |
8.0.0 | 已移除選用的 age 參數。 |
7.4.0 | 選用的 age 參數已被棄用;若有傳入值,則會被忽略。 |
範例 #1 curl_version() 範例
此範例將使用 curl_version() 返回的 'features'
位元遮罩來檢查 cURL 建置中可用的功能。
<?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) ? ' 相符' : ' 不相符');
echo PHP_EOL;
}
?>