php怎么获取当前url地址

php获取当前网址

$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://": "http://";//协议头
$siteurl = $protocol . $_SERVER['HTTP_HOST'];//站点网址

如果要获取当前完整的url地址

$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://": "http://";//协议头
$url = $protocol . $_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'];//完整的url地址

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: