function isSecure(): bool { return strtolower($_SERVER['HTTPS']) == 'on'; } function getProtocol(): string { return isSecure() ? 'https' : 'http'; }Example use:
if (isSecure()) { print "Secure connection\n"; } else { print "Non-secure connection\n"; }