How to determine if there is a place in a GET or POST key?

In PHP, if I have the following script:

var_dump($_REQUEST); 

How can I distinguish between the following queries:

 GET /foo?hello%20dude=cool GET /foo?hello_dude=cool 

both of them print:

 array(1) { ["hello_dude"]=> string(4) "cool" } 

since key names are not allowed to have spaces? Should I manually analyze the POST data as well as the GET data, or is there an easier way?

+5
source share
1 answer

I think you will have to bypass the automatic parsing of the PHP query string and do it yourself.

You can get the full request URI by checking $_SERVER['REQUEST_URI'] . From there you can break up the first question mark ? , then divide by ampersand & , and then divide by = . It can also be a convenient regular expression.

+1
source

Source: https://habr.com/ru/post/1200504/


All Articles