$host = $_SERVER['HTTP_HOST']
echo $host;//输出 baidu.com
$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ?"https://": "http://";
$url = $protocol . $_SERVER['HTTP_HOST'];
echo $url;//输出 https://baidu.com
echo $_SERVER['PHP_SELF'];//输出 /index.php/index/index/index
echo $_SERVER["QUERY_STRING"]; //输出 id=5
PHP获取当前URL 域名等
最新推荐文章于 2023-06-30 13:55:17 发布