I have checked all $_SERVER member var, still don't know how.
4 Answers
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
// do your stuff here...
3 Comments
quack quixote
is there some time that it will be
!= 'off' AND != 'on'?Franz
Yes. IIS with ISAPI. See Mauris' answer.
Franz
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.
$_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.
Comments
if you do print_r($_SERVER); => you can see this. [HTTPS] => on
1 Comment
lovespring
I don't have this var in my $_SERVER, why ?