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 248 views
1 answer 170 views
1 answer 295 views
1 answer 148 views
1 answer 142 views
1 answer 146 views
1 answer 171 views
...