Use feature_list Value Returned by curl_version Function in PHP 8.4

Use feature_list Value Returned by curl_version Function in PHP 8.4

The curl_version function in the Curl extension returns an associative array with information about the Curl version and build details. It also includes a bitmask of all features supported by Curl. The bitmask of features makes it neither intuitive nor easy to determine whether a specific feature (HTTP/3, Brotli, etc.) is supported in the Curl.

In PHP 8.4, the curl_version function returns an additional feature_list value, an associative array that lists all known Curl features and indicates whether each is supported.

<?php

$data = curl_version();

foreach ($data['feature_list'] as $feature => $supported) {
    echo $feature.': '.($supported ? 'true' : 'false').PHP_EOL;
}

This improves readability when checking whether specific features are supported in the Curl. Output example:

AsynchDNS: true
CharConv: false
Debug: false
GSS-Negotiate: false
IDN: true
IPv6: true
krb4: false
Largefile: true
libz: true
NTLM: true
...

Leave a Comment

Cancel reply

Your email address will not be published.