How to check (request) whether the page is called from http or https in PHP

2 Answers

0 votes
if (!empty($_SERVER['HTTPS'])) {
  echo 'https';
}
else {
    echo 'http';
}

 
/*
run:
 
http
 
*/

 



answered Feb 22, 2019 by avibootz
0 votes
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off')) {
  echo 'https';
}
else {
    echo 'http';
}

 
/*
run:
 
http
 
*/

 



answered Feb 22, 2019 by avibootz

Related questions

2 answers 253 views
1 answer 173 views
1 answer 297 views
1 answer 150 views
1 answer 144 views
1 answer 149 views
1 answer 173 views
...