Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL format with GET parameters?

Tags:

http

php

Is there a specification somewhere listing the correct way to pass GET variables to a URL?

Normally I do it like this (first variable indicated by ?, second and subsequent indicated by &:

http://www.mysite.com/mypage.html?var1=value1&var2=value2&var3=value3 

Are those ? and & specifically needed, and in those order? Could I eliminate the '?' and pass all variables only with the '&' ?

like image 295
mikew Avatar asked May 13 '11 22:05

mikew


People also ask

What is get parameter in URL?

GET parameters (also called URL parameters or query strings) are used when a client, such as a browser, requests a particular resource from a web server using the HTTP protocol. These parameters are usually name-value pairs, separated by an equals sign = . They can be used for a variety of things, as explained below.

How do you write parameters in URL?

To identify a URL parameter, refer to the portion of the URL that comes after a question mark (?). URL parameters are made of a key and a value, separated by an equal sign (=). Multiple parameters are each then separated by an ampersand (&).

How can I get parameters from a URL string?

The parameters from a URL string can be retrieved in PHP using parse_url() and parse_str() functions. Note: Page URL and the parameters are separated by the ? character. parse_url() Function: The parse_url() function is used to return the components of a URL by parsing it.


1 Answers

No, how you are doing it is correct.

http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.2

like image 140
Dustin Laine Avatar answered Oct 09 '22 04:10

Dustin Laine