Programming Tips - PHP: is this a secure connection (ie https)

Date: 2020may1 Language: php Q. PHP: is this a secure connection (ie https) A.
function isSecure() { return strtolower($_SERVER['HTTPS']) == 'on'; } function getProtocol() { return isSecure() ? 'https' : 'http'; }
Example use:
if (isSecure()) { print "Secure connection\n"; } else { print "Non-secure connection\n"; }