If you are our client most probably you know that has been some time we are running HTTP/2 support over LiteSpeed web server in all our cPanel shared web hosting services, which exponentially accelerate your web site loading, helping in your SEO ranking and also to keep visitors navigating in your web sites.
From now, we also support HTTP/2 with PHP, this is not for your web site loading but for PHP to perform HTTP/2 requests to remote servers via cURL functionality. This will add another layer of protection and also speedup the process using the next generation http protocol.
This is mainly a developer feature but we are sure in the near future most popular scripts developers will start taking advantages of it potential and this will effect in the popular scripts functioning like WordPress, Joomla, etc.
To check if this is working, you can either check the HTTP/2 feature in a phpinfo() at the cURL section. It should show as “Yes” (supported) or you can use the PHP code below in a file and access it with the url.
<?php
if (!defined(‘CURL_HTTP_VERSION_2_0’)) {
define(‘CURL_HTTP_VERSION_2_0’, 3);
}
$version = curl_version();
if ($version[“features”] & constant(‘CURL_VERSION_HTTP2’) !== 0) {
$url = “https://google.com/”;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_HEADER,1);
curl_setopt($ch,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2_0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
$response = curl_exec($ch);
if ($response !== false && strpos($response, “HTTP/2”) === 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.”;
}
echo “\n”;
?>
Enjoy!