How can I recode% D0% B8% D0% B3% D0% BE% D1% 80% D1% 8 into the word "Igor"?

Background: I installed a widget to access the site using the VKon VKontakte account. And he sends me in GET name, UID, last name, and a link to the picture. For example: <?php $hash = $_GET['hash']; $uid = $_GET['uid']; $first_name = $_GET['first_name']; $last_name = $_GET['last_name']; $photo = $_GET['photo']; ?> <p>Ваш UID:<?php echo $uid; ?></p> <p>Ваше имя:<?php echo urldecode($first_name); ?></p> <p>Ваша фамилия:<?php echo urldecode($last_name); ?></p><br> <img src='<?php echo $photo;?>'>` 

What he gives:

 Ваш UID:38039883 Ваше имя: Ваша фамилия: 

URLDECODE() does not help, or I do not understand how to work with it ... please explain!

  • How do you work with urldecode? - tehead September
  • What does he give out? - tehead
  • Added to the question. - igolka97 September
  • $_GET already contains decoded strings. Re-use urldecode() not necessary. What does echo $_GET['first_name'] just print? And, for beauty, print_r($_GET) please provide. - Sergiks
  • @srgiks, it displays an empty line ... - igolka97

2 answers 2

You need the rawurldecode function!


 echo rawurldecode('%D0%B8%D0%B3%D0%BE%D1%80%D1%8C'); 

Result: Igor

  • @ARISTARH, the whole problem, probably, is that it generally displays an empty field instead of% D0% B8% D0% B3% D0% BE% D1% 80% D1% 8C - igolka97
  • you generally need to describe the task in order to choose the desired solution! For example, VC has an API, and you can easily get an answer in the JSON string, or with CURL you can match something, in general there are many options! - Epexa
  • @ARISTARH, I use the API !!! I need to get the User Data and display it on the page. - igolka97 September
  • Separately create a question how to do it - Epexa

Try setting the page encoding to UTF-8. I think the problem may be this. If changing the encoding of the page does not lead to anything, then try the following option:

 echo iconv('cp1251','utf-8',$_GET['first_name']); 

PS Between rawurldecode () and urldecode () there is almost no difference, except that in urldecode the plus is decoded into a space character.