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 173 views
1 answer 297 views
1 answer 151 views
1 answer 144 views
1 answer 149 views
1 answer 184 views
...