[PHP] Get Site URL Protocol "HTTP or HTTPS" - In this case, some PHP developers need to check the protocol of the site is using HTTP or HTTPS. For example: on local server still using HTTP protocol while on the online server is using HTTP protocol.
So, the developers need to determine a variables that need HTTP or HTTPS. Below is the sample code for determine it.
Done, it is a sample code for [PHP] Get Site URL Protocol "HTTP or HTTPS".
<?php
// checking $protocol in HTTP or HTTPS
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
// this is HTTPS
$protocol = "https";
} else {
// this is HTTP
$protocol = "http";
}
?>
Paper 4Share - [PHP] Get Site URL Protocol "HTTP or HTTPS"
![[PHP] Get Site URL Protocol "HTTP or HTTPS" [PHP] Get Site URL Protocol "HTTP or HTTPS"](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZk4T9fxdRD6a7b_HLgkSGSu8Ptxk5SudJIxC_FJTzcF0WxuG1535sMZUIxbcQ0o0MYYKf4Zgs8b5f2GIE-UCKD2-I2XLvXVVNJxpXysMiOV5-r1V2tdDc0UamDy4VNItoP832sYLHt48d/s400/php-get-site-url-protocol-http-or-https.png)
0 Response to "[PHP] Get Site URL Protocol "HTTP or HTTPS""
Post a Comment