Mobile app version of vmapp.org
Login or Join
Gonzalez347

: Should query string parameter values in a URI have single quotes around them? I'm passing variables through the URI string, like this: example.com?a=first&b=second Everything works as intended,

@Gonzalez347

Posted in: #Links #Php #Url

I'm passing variables through the URI string, like this:

example.com?a=first&b=second


Everything works as intended, but when I pass the source code through the W3 validator, it's flagging them as errors. When I quote the variables, like this:

example.com?a='first'&b='second'


they do not get flagged. I've never seen a website do this, but is that the proper way to pass these variables? I could not find any source that recommends quoting them in the URI.

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gonzalez347

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

<a href="link.php?a=first&b=second">Click here!</a>


The only thing that might get flagged in that anchor is the unencoded &. The & should be HTML encoded. ie. &amp; (in order to avoid potential conflict). URL parameters certainly should not be quoted as a general rule.

The URL, by its very nature, is all a "string", so quoting URL parameter values for the sake of it does not make sense, unless you explicitly needed this for your script (although this should probably be avoided, as it just adds clutter).

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme