Return to Snippet

Revision: 55018
at January 22, 2012 10:05 by kf0l

Initial Code
if (isset($_SERVER['HTTPS']) &&
        strtolower($_SERVER['HTTPS']) == 'on') {
        $protocol = 'https://';
    } else {
        $protocol = 'http://';

Initial URL

Initial Description
This 'Check if HTTPS is on in PHP'  script accounts for servers which set HTTPS differently. Some servers do not set HTTPS, others set it to 'off', etc. Only checking if HTTPS is on will cause an 'undefined index error' in these cases.

Initial Title
Check if HTTPS is on in PHP

Initial Tags
http, php

Initial Language