Posted By

kf0l on 01/22/12


Tagged

http php protocol https


Versions (?)

Check if HTTPS is on in PHP


 / Published in: PHP
 

URL: check_if_https_is_on_in_php

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.

  1. if (isset($_SERVER['HTTPS']) &&
  2. strtolower($_SERVER['HTTPS']) == 'on') {
  3. $protocol = 'https://';
  4. } else {
  5. $protocol = 'http://';
  6. }

Report this snippet  

You need to login to post a comment.