defined('CURL_VERSION_HTTP2') || define('CURL_VERSION_HTTP2', 65536); defined('CURL_HTTP_VERSION_2_0') || define('CURL_HTTP_VERSION_2_0', 3); defined('CURL_HTTP_VERSION_2') || define('CURL_HTTP_VERSION_2', CURL_HTTP_VERSION_2_0); defined('CURLPIPE_NOTHING') || define(CURLPIPE_NOTHING, 0); defined('CURLPIPE_HTTP1') || define('CURLPIPE_HTTP1', 1); defined('CURLPIPE_MULTIPLEX') || define('CURLPIPE_MULTIPLEX', 2); if (curl_version()["features"] & CURL_VERSION_HTTP2 !== 0) { $url = "https://www.google.com/"; $ch = curl_init(); curl_setopt_array($ch, [ CURLOPT_URL =>$url, CURLOPT_HEADER =>true, CURLOPT_NOBODY =>true, CURLOPT_RETURNTRANSFER =>true, CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_2_0, ]); $response = curl_exec($ch); if ($response !== false && strpos($response, "HTTP/2.0") === 0) { echo "HTTP/2 support!"; } elseif ($response !== false) { echo "No HTTP/2 support on server."; } else { echo curl_error($ch); } curl_close($ch); } else { echo "No HTTP/2 support on client."; }