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 254 views
1 answer 392 views
1 answer 256 views
1 answer 225 views
1 answer 230 views
1 answer 275 views
...