4

How can i catch the current full url including the # sign when it is in it?

My url looks like this: http://example.com/spf#users/admin

When using this code:

$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $url;

he outputs this only: http://example.com/spf It should also catch the #users/admin behind it

Jack Maessen
  • 1,780
  • 4
  • 19
  • 51
  • 2
    PHP doesn't receive the fragment information because it's client-only. You can catch it with javascript though. – Daan Apr 11 '16 at 11:14

2 Answers2

4

Plz Refer Below Link

Get Full Url in PHP

at Client Side You can use javascript to get hash value with window.location.hash

Community
  • 1
  • 1
Tarun Bhati
  • 141
  • 7
2

This isn't possible with "standard" HTTP to get the URL fragment as this value is never sent to the server. You would need following JavaScript on the client side.

Use window.location.hash in JavaScript and do any operation.

David Ferenczy Rogožan
  • 23,966
  • 9
  • 79
  • 68
prava
  • 3,916
  • 2
  • 24
  • 35