php取得跳轉前的url方法:1、取得URL帶QUESTRING參數的JAVASCRIPT客戶端方法;2、正規分析法,設定或取得整個URL為字串,程式碼為【alert(window. location.href)】。
php取得跳轉前的url方法:
一:取得URL帶QUESTRING參數的JAVASCRIPT客戶端解決方案,相當於asp的request.querystring,PHP的$_GET
#1.函數:
2.然後透過呼叫此函數取得對應參數值:
以此取得url字串中所帶的同名參數
二、正規分析法。
function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (r!=null) return (r[2]); return null; } alert(GetQueryString("参数名1")); alert(GetQueryString("参数名2")); alert(GetQueryString("参数名3"));
其他參數取得介紹:
//設定或取得物件指定的檔案名稱或路徑。
alert(window.location.pathname);
//設定或取得整個 URL為字串。
alert(window.location.href);
//設定或取得與 URL關聯的連接埠號碼。
alert(window.location.port);
//設定或取得 URL的協定部分。
alert(window.location.protocol);
//設定或取得 href屬性在井號「#」後面的分段。
alert(window.location.hash);
//設定或取得 location 或 URL 的hostname 和 port 號碼。
alert(window.location.host);
//設定或取得 href屬性中跟在問號後面的部分。
alert(window.location.search);
相關學習推薦:php程式設計(影片)
以上是php如何取得跳轉前的url的詳細內容。更多資訊請關注PHP中文網其他相關文章!