[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.
1 2 3 4 5 6 7 8 9 10 | <?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"; } ?> |
Done, it is a sample code for [PHP] Get Site URL Protocol "HTTP or HTTPS".
You need to know:
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/AVvXsEiSnzRNvYrK7CacK0JtFcaCmMimxwocIBpGW4FvjlwOaYGIbFPrRik6YSt7xsDJ9CohZkQXF6EIVGWVnooe2djQelGaw-r1tBM_b50bJkCPQNMmmPF9GqoOhfQFcq0hwYjvBSt6YwVWAbAh/s200/php-get-site-url-protocol-http-or-https.png)