PHP queries with multiple query strings

I can always check this out, but I wanted to get an official response from a PHP expert (I definitely don’t know something).

If someone makes such a request:

http://www.somedomain.com/a.php?param1=value1&param2=value2&param3=value3?param1=value4&param2=value5&param3=value6 

What are the consequences of trying to access _GET['param2'] , for example? Looks like I just got the first value. In this case, it will return value2 . Is this expected behavior?

Does the second question mark mean? Will there be errors, for example?

+7
source share
2 answers

He simply identifies the latter. Defining a parameter more than once in a query string simply leads to the risk of potentially confusing results. It is best to check your query string in these cases, at least on what I am doing.

The second question mark will be considered as part of the value for its previous parameter.

+3
source

You, officially, should not have two ? in the query string. If you do this, the results will be undefined. Will some platforms (e.g. PHP) handle the following characters ? just like the & characters, and allow these values ​​/ pairs. Others will consider param3 as value3?param1=value4 .

Short answer: do not do this. He becomes awkward. And, as the author of the server, you always need to carefully check the parameter values ​​to make sure that the values ​​make sense.

+2
source

All Articles