Check if a website is using SSL using CURL
<p>I'm building a script that will check if a website is using SSL or not. For example, we use "<a href="http://www.google.com/" rel="noreferrer">http://www.google.com/</a>" it will be redirected to "<a href="https://www.google.com/" rel="noreferrer">https://www.google.com/</a>". How can I check that? I'm using the following cURL codes to get headers of a website. </p>

<pre><code>&lt;?php
$url = 'https://www.google.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url); // set url
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); // set browser/user agent
curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'read_header'); // get header
curl_exec($ch);

function read_header($ch, $string) {
    print "Received header: $string";
    return strlen($string);
}
?&gt;
</code></pre>

<p>Output:</p>

<pre><code>HTTP/1.1 302 Found 
Cache-Control: private 
Content-Type: text/html; charset=UTF-8 
Location: https://www.google.co.in/?gfe_rd=cr&amp;ei=YEAkV7SEFrTv8wexyy0 
Content-Length: 259 
Date: Sat, 30 Apr 2016 05:19:28 GMT 
Alternate-Protocol: 443:quic 
Alt-Svc: quic=":443"; ma=2592000; v="33,32,31,30,29,28,27,26,25" 
</code></pre>