How to check whether page URL contain HTTP or HTTPS in PHP

2 Answers

0 votes
$http_header = 'http://';
if (!empty($_SERVER['HTTPS'])) 
    $http_header = 'https://';

echo $http_header;


/*
run: 

http://

*/

 



answered Jul 10, 2017 by avibootz
0 votes
$http_header = 'http://';
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT']==443) 
    $http_header = 'https://';

echo $http_header;


/*
run: 

http://

*/

 



answered Jul 10, 2017 by avibootz

Related questions

1 answer 169 views
1 answer 295 views
1 answer 147 views
1 answer 142 views
1 answer 145 views
1 answer 181 views
...