Home  >  Article  >  Backend Development  >  How to accurately obtain the current url in php

How to accurately obtain the current url in php

WBOY
WBOYOriginal
2016-08-08 09:29:441130browse

The blogger is keen on various Internet technologies. He is often wordy and often accompanied by obsessive-compulsive disorder. He updates frequently. If you think the article is helpful to you, you can follow me. Please indicate "Dark Blue Sickle" when reprinting


$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
$url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

The above introduces the method of accurately obtaining the current URL in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn