I have checked all $_SERVER member var, still don't know how.
+1
A:
$_SERVER['HTTPS'] == 'on'
upd: and $_SERVER['SERVER_PROTOCOL'] or $_SERVER['SERVER_PORT'] == 443//80 for http
x2
2009-11-05 05:08:19
+3
A:
$_SERVER['HTTPS'] - from http://php.net/manual/en/reserved.variables.server.php
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
thephpdeveloper
2009-11-05 05:08:38
+5
A:
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
// do your stuff here...
Franz
2009-11-05 05:09:34
is there some time that it will be `!= 'off'` __AND__ `!= 'on'`?
quack quixote
2009-11-05 05:15:41
Yes. IIS with ISAPI. See Mauris' answer.
Franz
2009-11-05 05:18:43
Ah, my bad. That comment was actually the right answer, but not to your question, @quack. I don't know of any other case. However, as Mauris' wrote, IIS sets the value to 'off' when using ISAPI which is why the second part of the condition is necessary.
Franz
2009-11-05 06:56:08