My question is related to this one. except that my question is more sepcific as it is about whether a hyphen can be used in a query string parameter value.
I am parsing $_SERVER['QUERY_STRING']
with PHP. I would like to know whether it is syntactically correct to use hyphens in query string values such as in the following case, or whether hyphens must be escaped in the browser URL. What about underscores?
http://example.com/?q1=query-string-value-one&q2=query-string-value-two
According to this document hyphens should be OK in all standards-compliant browsers, but I wanted to double check.
Thanks.
You are talking about query string parameters which must be encoded using urlencode
function:
This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.
According to the documentation -
does not require encoding.