I can always test this, but I wanted an official answer from a PHP expert (something I am most certainly not).
If someone makes a request like this:
http://www.somedomain.com/a.php?param1=value1¶m2=value2¶m3=value3?param1=value4¶m2=value5¶m3=value6
What kinds of consequences are there when I try to access _GET['param2']
, for example? It looks like I just get the first value. In this case, it would return value2
. Is that expected behavior?
Does the second question mark affect anything? Will there be errors, for example?
It just gets the last one defined. Defining a parameter more than once in the query string just runs the risk of getting potentially confusing results. It's best to validate your query string in these instances, at least that's what I do.
The second question mark will be treated as part of the value for its preceding parameter.
You are, officially, not supposed to have two ?
in a query string. If you do, the results are undefined. Some platforms (such as PHP) will treat subsequent ?
chars the same as &
chars, and allow those value/pairs. Others will just treat the value for param3
to be value3?param1=value4
.
Short answer: don't do this. It gets wonky. And, as a server author, one should always be validating parameter values carefully to make sure the values make sense.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With