What is the difference between; and & in a URL?

25

I was looking at a website to add in a C # application, I noticed a link similar to this:

www.site.com.br/index.php?post=yes;user=1521;

The parameters are separated by ; (semicolon). I accessed the same page by changing the ; (semicolon) by% com_and% ('and' commercial):

www.site.com.br/index.php?post=yes&user=1521

The page was loaded normally, is there a difference between & and ; ?

    
asked by Leonardo Vilarinho 26.01.2016 в 18:11
source

4 answers

10

No commented link by @Bacco we have the following definition:

  
  • The query string is composed of a series of field-value pairs.
  •   
  • Within each pair, the field name and value are separated by an equals sign, '='.
  •   
  • The series of pairs is separated by the ampersand, '&'; (or semicolon, ';' for URLs embedded in HTML and not generated by a ...; see below).
  •   

Summarizing a little:

  
  • The query string consists of pairs of campos=valor
  •   
  • Each pair string is separated by & , or ; if not from a form.
  •   

However, I would like to show the following:

If I access a URL like this:

  

www.site.com.br/index.php?post=yes|user=1521|pass=123|uf=RS

     

www.site.com.br/index.php?post|yes|user|1521|pass|123|uf|RS

Do you think it might not work?

The fact is that what comes after ? will usually get caught by the GET of the language you're working on, and this information will be string , as your code will interpret what comes will depend of its coding.

    
answered by 29.01.2016 / 17:22
source
6

The semicolon character ; (aka "semicolon") can be used as a parameter separator in a URL. However the% ampersand% character is the default by general convention.

The semicolon is a subdellor. The use is applicable in specific schemas. Example, the "Prospero" schema:

prospero://<host>:<port>/<hsoname>;<field>=<value>

link

Note that the comma & is also a valid separator, but under the same context because both are classified as sub-editors, according to rfc3986 .

See also: link

    
answered by 01.02.2016 в 05:25
1

O; is reserved and can be used by servers for a type of data separation, as in its example clearly happens, while & is usually used for separating GET parameters. O ; can however have another use / meaning with another server, for example may have systems that use; within the part behind the & to separate multiple parts of the response.

In practice it has relatively few standard server software, and within each of these it can have a relatively uniform handling of these symbols. However, each server does have every right to use these symbols as it best suits the application it is running, so it is by no means guaranteed that & and ; are always equivalent.

In your case it uses C # and the standard APIs seem to treat everything the same way. But because in C # you can create your own style of handling everything, nor here it is 100% guaranteed. It's just so because it's preset like this.

More relevant information: link

    
answered by 01.02.2016 в 14:38
0

Briefly this is it:

If you use & or ; in query string generated by the code itself (HTML, or JS) for separating parameters.

However, & can be used also in query string generated by FORM , ; not .

    
answered by 29.01.2016 в 14:43