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 256 views
1 answer 175 views
1 answer 300 views
1 answer 155 views
1 answer 146 views
1 answer 152 views
1 answer 175 views
...