Php method for obtaining the & value in url parameters _ PHP Tutorial

Source: Internet
Author: User
Php obtains the value of & amp; in url parameters. In actual projects, we often encounter the path to get the previous page address. You can return to the previous page and copy the code as follows: scriptwindow. history. go (-1); in actual project process, we often encounter the path to obtain the previous page address. You can return to the previous page to use

The code is as follows:


Script window. history. go (-1); script


This is operated through JS.

In such a scenario, when the user needs to exit the account, you want him to exit directly on the current page

For example, the current page address is http: // xxx/module. php? Module = groupbook & view = index & id = 2.

When you exit the system, you must use $ _ SERVER ['request _ URI '] to obtain the current path, and then pass this value as a parameter to the path to be returned for exit.

He only obtained http: // xxx/module. php? Module = groupbook does not get & view = index & id = 2, which means the address returned after we exit is changed

Http: // xxx/module. php? Module = groupbook (this should be http: // xxx/module. php? Module = groupbook & view = index & id = 2 ),

This is because he regards & as the first parameter, which is simply understood

Http: // xxx/login. php? Op = logout & return = http: // xxx/module. php? Module = groupbook & view = index & id = 2,

Changed

Http: // xxx/login. php? Op = logout & return = http: // xxx/module. php? Module = groupbook & view = index & id = 2.

In this case, you need to use urlencode ($ _ SERVER ['request _ URI ']) to transcode the currently obtained $ _ SERVER ['request _ URI'].

We can solve our problem.

Bytes. You can return to the previous page using the following code: scriptwindow. history. go (-1);/script this...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.