PHP with HTTP/2 support for CURL

PHP with HTTP/2 support for CURL

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.


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 = “”;

$ch = curl_init();






$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);



} else {

echo “No HTTP/2 support on client.”;


echo “\n”;




Table of Contents

Recent Posts

You May also be Interested

Non-Secure Website Alert Even When You Have An SSL Certificate

Non-Secure Website Alert Even When You Have An SSL Certificate

Most of the modern web browsers such as Google Chrome and Mozilla Firefox will show a “not-secure” warning to visitors if you have an element of your site which is not deemed secure. This could be caused by an image or a link to external CSS and more.

21 Ways To Keep WordPress Secure

In general, WordPress is secure but from time to time it is vulnerable. You can minimize this vulnerability by following our 21 ways to keep your WordPress installations secure. Keeping everything up to date is essential. It is essential that you do everything possible to reduce security risks.

Avoid Your WordPress Sites Being Used For Phishing Or Spam

WordPress is the world’s most popular content management system (CMS) for a lot of very good reasons. You can setup a new WordPress site on a domain name very fast these days with the one click installation software that is available in cPanel with your premium web hosting service.