php獲取當前頁面的完整url

2022-09-16 13:48:09 字數 1035 閱讀 3427

j**ascript實現:

top.location.href   頂級視窗的位址

this.location.href 當前視窗的位址

php實現: 

//測試**:

http://localhost/blog/test.php?id=1

//獲取網域名稱或主機位址

//獲取網頁位址

echo $_server['php_self']."

"; #/blog/test.php

//獲取**引數

echo $_server["query_string"]."

"; #id=5

//獲取使用者**

"; //獲取完整的url

//包含埠號的完整url

//只取路徑

PHP中獲取當前頁面的完整URL

top.location href 頂級視窗的位址 this.location href 當前視窗的位址 測試 http localhost blog testurl.php?id 5 獲取網域名稱或主機位址 獲取網頁位址 echo server php self blog testurl.php ...

PHP中獲取當前頁面的完整URL

1 來自 http 測試 http localhost blog testurl.php?id 545 獲取網域名稱或主機位址 獲取網頁位址 9echo server php self blog testurl.php 1011 獲取 引數 12echo server query string id...

獲取當前頁面的URL

window location host 返回url 的主機部分,例如 www.com window location hostname 返回www.com window location href 返回整個url字串 window location pathname 返回 a index.php或...