Get the Current Request Protocol

This is the defacto standard way to return the protocol of the current request.

PHP Code

function Request_Protocol() {
	/*
	Purpose
		Used to get the protocol used in the current request.
	Return (string)
		Returns "http" or "https" depending on the current protocol.
	Version History
		1.0 2016.06.23 Tested by Russ Tanner on PHP 5.3.10 and 5.6.1.
	*/

	return (
		( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ) ||
		( isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' )
	) ? 'https' : 'http';
}
 


Last edited by Russ; 06/23/16 06:46 PM.

The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)