Home>Article>Backend Development> How to get the url before jump in php
php method to get the url before jumping: 1. JAVASCRIPT client method to get the URL with QUESTRING parameter; 2. Regular analysis method, set or get the entire URL as a string, the code is [alert(window. location.href)].
php method to get the url before jump:
1: Get the JAVASCRIPT client of the URL with QUESTRING parameter Solution, equivalent to asp's request.querystring, PHP's$_GET
1. Function:
2. Then get the corresponding parameter value by calling this function:
Use this to obtain the parameter with the same name in the url string
2. Regular analysis method.
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"));
Other parameter acquisition introduction:
//Set or get the file name or path specified by the object.
alert(window.location.pathname);
//Set or get the entire URL as a string.
alert(window.location.href);
//Set or get the port number associated with the URL.
alert(window.location.port);
//Set or get the protocol part of the URL.
alert(window.location.protocol);
//Set or get the segment after the pound sign "#" in the href attribute.
alert(window.location.hash);
//Set or get the hostname and port number of location or URL.
alert(window.location.host);
//Set or get the part following the question mark in the href attribute.
alert(window.location.search);
Related learning recommendations:php programming(video)
The above is the detailed content of How to get the url before jump in php. For more information, please follow other related articles on the PHP Chinese website!