This article mainly introduces the function for PHP to obtain the current complete URL address. For more information, see
This article mainly introduces the function for PHP to obtain the current complete URL address. For more information, see
Here we will share with you a very practical PHP function. The code is very simple and there will be no nonsense. If you need it, you can use it directly.
The Code is as follows:
// Php retrieves the complete url of the current access
Function get_current_url (){
$ Current_url = 'HTTP ://';
If (isset ($ _ SERVER ['https']) & $ _ SERVER ['https'] = 'on '){
$ Current_url = 'https ://';
}
If ($ _ SERVER ['server _ port']! = '80 '){
$ Current_url. = $ _ SERVER ['server _ name']. ':'. $ _ SERVER ['server _ port']. $ _ SERVER ['request _ URI '];
} Else {
$ Current_url. = $ _ SERVER ['server _ name']. $ _ SERVER ['request _ URI '];
}
Return $ current_url;
}
,