Here I am trying to encode a URL containing a GET request. The scheme is approximately as follows:


As you understood, of course, the GET request is


So I'm trying to encode this string so that the link can go, and the server has processed this request. I tried using urlencode () , the result:


It seems to be all right, as it seems at first glance ... but I am querying the query data (namely, what comes after the question mark, i.e. "_spirix __.-% 5E% 5B% 5D% 23% 2A% 25% 21 ~ % 40% 2B " ), and this is what I get:


Why? Where are the remaining coded characters ([] # *%! ~ @ +) ??? Maybe someone faced a similar problem, guys?

Many thanks to those who help!

3 answers 3

Most likely, business in [].

An array is formed.

 Array ( [_spirix___-^] => Array ( [0] => ) ) 1 

and without [ normal

 Array ( [_spirix___-^]#*%!~@+] => ) 1 
  • Yes you are right! The case really turned out to be in brackets! Not even in brackets, but in one "[". I will think how to correct. Thank you - Salivan

Try rawurlencode ( string $str )


  • I tried. Does not work. --- Yes, and besides, there is almost no coding difference between these functions. Only different standards are used ... - Salivan
  • do you decode it rawurldecode ??? - Maksym Prus
  • @ROOT, and so also tried - does not help ((( - Salivan
 $test = urlencode('_spirix__.-^[]#*%!~@+'); var_dump(urldecode($test)); //string(21) "_spirix__.-^[]#*%!~@+" 

works fine

  • It's a matter of a GET request ... this is how it works for me too ... - Salivan