Query string
|
A query string is the part of a URL that conveys parametric data to the server.
Contents |
Syntax
The basic syntax is ?parameter1=value1¶meter2=value2 . . .
- The query string starts with a question mark.
- Then follows a series of parameter=value pairs. For example, Message=hello.
- The parameter-value pairs are each separated by an equal sign.
- The series of pairs is separated by the ampersand, '&'. (The W3C recommends supporting ";" in place of "&". [1] (http://www.w3.org/TR/1999/REC-html401-19991224/appendix/notes.html#h-B.2.2))
URL Encoding
Spaces, ampersands, equal signs, and many other characters could cause trouble with the URL and the query string. Therefore the value in each parameter-value pair is URL-Encoded. This is a process by which each of these troublesome characters is converted into a numeric represenctation.
'%2D' is one such example.
- The percent sign signals the start of such a string.
- '2D' is the number 45 in HEX - in ASCII and UNICODE, each character has a numerical index.
Therefore, %2D is the minus sign, and %25 is the percent character.
Quirks
- Spaces are converted to plus signs, e.g. "hello there" would be converted to hello+there.