Php obtains the names and values of all variables passed in the GET method.

Source: Internet
Author: User
The requirement of this blog is that I need to send an http request such as 127.0.0.1? A = 123 & amp; B = 456 & amp; c = 789 obtain all the get parameters and concatenate them to the end of test.com, that is, the final ideal uri should be test.com? A = 123 & amp; B = 456 & amp; c = 789 two methods can be implemented. we recommend that you first google ,... "/> The requirement of this blog is that I need to send an http request such as 127.0.0.1? A = 123 & B = 456 & c = 789 obtain all the get parameters and concatenate them to the end of test.com. that is, the final ideal uri should be test.com? A = 123 & B = 456 & c = 789 can be implemented in two ways. we recommend that you first google, I just didn't use google to cause rework $ _ SERVER ["QUERY_STRING"]. this is the simplest method, but most people may not be familiar with this SERVER variable, [html] $ _ SERVER ["QUERY_STRING"]: query string code [php] $ base = "test.com"; $ str = $ _ SERVER ["QUERY_STRING"]; $ uri = $ base. $ str; echo $ uri; effect $ _ GET array for loop concatenating ideas most people encounter this requirement. The first response should be a for loop GET array, write an implementation code to share the code [php] $ str = "test.com? "; $ Count = count ($ _ GET); $ I = 0; www.2cto.com foreach ($ _ GET as $ key => $ value) {if ($ I = $ count-1) {$ str. = $ key. "= ". $ value;} else {$ str. = $ key. "= ". $ value. "&" ;}$ I ++;} echo $ str; effect

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.