Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Kodowanie requrest-a
michal_robak
post
Post #1





Grupa: Zarejestrowani
Postów: 115
Pomógł: 12
Dołączył: 13.05.2006

Ostrzeżenie: (0%)
-----


Witam,

mam problem z kodowaniem polskich znaków gdy przekazauje je w pojedyńczych apostrofach. Przesyłam kod:

  1. <?php
  2. //Enter your code here, enjoy!
  3.  
  4. $url = 'http://test.dev/users?&filter=email like %27%da%%27';
  5.  
  6. var_dump(utf8_decode(urldecode($url)));
  7. ?>


Online php parser:
http://sandbox.onlinephpfunctions.com/

wyrażenie '%da%' zamienia mi na binarny ciąg znaków. Teoretycznie mógłbym przesyłać 'da' ale to co jest w GET podstawiam pod LIKE w query builder w symfony.

Jak sobie z tym poradzić aby zwracał poprawne kodowanie ?
Go to the top of the page
+Quote Post
Tomplus
post
Post #2





Grupa: Zarejestrowani
Postów: 1 879
Pomógł: 230
Dołączył: 20.03.2005
Skąd: Będzin

Ostrzeżenie: (0%)
-----


Myślę że to rozwiąże problem:
  1. $url = 'http://test.dev/users?&filter='.urlencode("email like '%da%'");


Ten post edytował Tomplus 2.11.2017, 09:28:11
Go to the top of the page
+Quote Post
viking
post
Post #3





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A w jaki sposób pobierasz te dane? Z dokumentacji

Warning
The superglobals $_GET and $_REQUEST are already decoded. Using urldecode() on an element in $_GET or $_REQUEST could have unexpected and dangerous results
Go to the top of the page
+Quote Post
michal_robak
post
Post #4





Grupa: Zarejestrowani
Postów: 115
Pomógł: 12
Dołączył: 13.05.2006

Ostrzeżenie: (0%)
-----


Cytat(Tomplus @ 2.11.2017, 09:27:44 ) *
Myślę że to rozwiąże problem:
  1. $url = 'http://test.dev/users?&filter='.urlencode("email like '%da%'");


nie, ja nie chcę zakodować url-a tylko go zdekodować. Do api przesyłam tak:

http://moj_adres/api/users?filter=firstName+like+%27%da%%27

potem w kodzie mam coś takiego:

  1. $filters = urldecode($this->query->get('filter', ''));


gzie
  1. $this->query

jest brane z Symfon-owego Request-a
Go to the top of the page
+Quote Post
viking
post
Post #5





Grupa: Zarejestrowani
Postów: 6 380
Pomógł: 1116
Dołączył: 30.08.2006

Ostrzeżenie: (0%)
-----


A czytałeś to co wyżej wkleiłem?
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 22:30