How to get the url before jump in php

coldplay.xixi
Release: 2023-03-04 09:38:01
original
3725 people have browsed it

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)].

How to get the url before jump in php

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:

Copy after login

2. Then get the corresponding parameter value by calling this function:

Copy after login

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"));
Copy after login

Other parameter acquisition introduction:

//Set or get the file name or path specified by the object.

alert(window.location.pathname);
Copy after login

//Set or get the entire URL as a string.

alert(window.location.href);
Copy after login

//Set or get the port number associated with the URL.

alert(window.location.port);
Copy after login

//Set or get the protocol part of the URL.

alert(window.location.protocol);
Copy after login

//Set or get the segment after the pound sign "#" in the href attribute.

alert(window.location.hash);
Copy after login

//Set or get the hostname and port number of location or URL.

alert(window.location.host);
Copy after login

//Set or get the part following the question mark in the href attribute.

alert(window.location.search);
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!