0

URL: example.com/search:#searchWord

Since the # is not send to the server, it is changed to %23.

In the search page I want to display

Results for: #searchWord

But what I get is %23searchWord. I tried htmlspecialchars(), but nothing happens.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ben
  • 1,906
  • 10
  • 31
  • 47

2 Answers2

3

To achieve your goal use urldecode.

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
1
echo urlencode('example.com/search:#searchWord');
// output: example.com%2Fsearch%3A%23searchWord

echo urldecode('example.com%2Fsearch%3A%23searchWord');
// output: example.com/search:#searchWord
Bibhas Debnath
  • 14,559
  • 17
  • 68
  • 96