📜  php 当前页面 url - PHP 代码示例

📅  最后修改于: 2022-03-11 14:53:36.450000             🧑  作者: Mango

代码示例4
$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
$host     = $_SERVER['HTTP_HOST'];
$script   = $_SERVER['SCRIPT_NAME'];
$params   = $_SERVER['QUERY_STRING'];
 
$currentUrl = $protocol . '://' . $host . $script . '?' . $params;
 
echo $currentUrl;