PHP Tutorial : Get Protocol

I saw this problem/question on a few forums and I finded it useful to post on my blog too due to low results on google that gives you what you need. So,  how to get the protocol of a URL using php?  Have a look :

<?php
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))==’https’?'https’:'http’;

print “The protocol is $protocol”;
?>

Tadaaa!

Read PHP Tutorial : Get Protocol »