PHP 獲取當前訪問的完整URL

代碼以下:php

<?php

// php 獲取當前訪問的完整url
function GetCurUrl() {
	$url = 'http://';
	if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
		$url = 'https://';
	}
	
	// 判斷端口
	if($_SERVER['SERVER_PORT'] != '80') {
		$url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . ':' . $_SERVER['REQUEST_URI'];
	} else {
		$url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['REQUEST_URI'];
	}
	
	return $url;
}
相關文章
相關標籤/搜索