1

I am trying to send a url like this for search data

http://localhost/project/search/text:75%

I am getting 400 - Bad Request error in here.

I even tried replacing percentage with %25. But it didn't worked. How should I send the search data containing percentage?

Ganesh Babu
  • 3,590
  • 11
  • 34
  • 67

1 Answers1

1

In URLs, the % percent character is reserved for character encoding. Usually to represent a % character you can use %25, but as you have already tried this and that it doesn't work for you, you should instead use PHP's urlencode function like so:

$url=urlencode("text:%75");

The same issue occurs with :, this therefore prevents the same issue with this character also (which for reference is %3A).

Partially from this question.

Community
  • 1
  • 1
AStopher
  • 4,207
  • 11
  • 50
  • 75
  • @GaneshBabu.T.Y Your PHP installation has problems then, because the two methods I list work properly. – AStopher Feb 15 '15 at 16:40