How to retrieve http or https in URI
<p>I need to do something based on either http or https. For example:</p>

<pre><code>$https = strpos($_SERVER['REQUEST_URI'], 'https') !== false;
if ($https) { ?&gt;
    &lt;script type="text/javascript"&gt;
    var a = 'a';
    &lt;/script&gt;
&lt;?php } else { ?&gt;
    &lt;script type="text/javascript"&gt;
    var b = 'b';
    &lt;/script&gt;
&lt;?php } ?&gt;
</code></pre>

<p>But this doesn't work. It always goes to the second option regardless the page I access is http or https. Is there any work around? Thanks in advance.</p>
