Hello!

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

http://site.com/profile?_spirix__.-^[]#*%!~@+ 

As you understood, of course, the GET request is

 _spirix__.-^[]#*%!~@+ 

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:

 http://site.com/profile?_spirix__.-%5E%5B%5D%23%2A%25%21~%40%2B 

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:

  _spirix___-^ 

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 )

rawurlencode

  • 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