PHP Tutorial : Get Protocol
Jun 2, 2009 Useful PHP
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!
Tags: detect protocol, get protocol, php detect protocol, php get protocol, php protocol, protocol


Leave a Reply