Detailed explanation of how to determine whether http or https is used for php and how to obtain the current url
As shown below:
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'; echo $http_type . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>
The above detailed explanation of the judging whether http or https in PHP and how to obtain the current URL is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.
Related Articles
Detailed explanation of PHP using mb_string to process windows Chinese characters
If you want to batch process a bunch of files you downloaded before, match the key content in the file with regular rules and process them centrally. One problem encountered when operating files is the encoding problem in the Windows operating system. This article will discuss this issue in detail.2021-05-05Solution to the PHP empty function error report
This article mainly introduces the solution to the PHP empty function in detecting an error in a non-variable situation. Friends who need it can refer to it2014-03-03Reasons and strategies for failing to upload large files in php
This article mainly introduces the reasons and response strategies for the failure of PHP to upload large files. The sample code in the article is introduced in detail and has certain reference value. Interested friends can refer to it.2015-10-10Analysis on how to use memcached long connection of PHP expansion module
This article mainly introduces the use method of the PHP expansion module memcached long connection. Friends who need it can refer to it2014-12-12How to easily output complete SQL statements in Laravel
This article mainly introduces you to relevant information about how to easily output complete SQL statements in Laravel. The article introduces the example code in detail, which has certain reference learning value for everyone's learning or using Laravel. If you need it, let's learn together.2020-07-07Detailed explanation of the method to solve the Chinese garbled code of ajax+php
This article provides a detailed analysis and introduction to the method of Chinese garbled code in ajax+php. If you need it, please refer to it.2013-06-06PHP Verification Code Generator
This article mainly introduces the relevant code of the php verification code generator in detail, which has certain reference value. Interested friends can refer to it.2017-05-05Reading efficiency of php text files
I have been trying to store the homepage of the blog in the file, but it turns out that it is in the file. When the blog is updated, the content will be written to the file again. So I just tested three common methods of reading text2012-02-02Common measures for PHP to prevent SQL injection, CSRF and XSS attacks
When developing PHP applications, ensuring the security of the application is crucial. SQL injection, CSRF (cross-site request forgery) and XSS (cross-site scripting attacks) are some common security threats. This article introduces to you the common measures for PHP to prevent SQL injection, CSRF and XSS attacks. Friends who need it can refer to it.2023-11-11Summary of methods for generating short URLs in PHP
This article summarizes three methods to use php to generate short URLs. The first is PHP+MySQl to achieve the generation and reading of short URLs. The second is the php+ini method. The third is somewhat similar to the first one. Each has its pros and cons. Friends can choose according to their project needs.2016-07-07