$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.