1

Possible Duplicate:
How to get the value after the hash in “somepage.php#name”?

Is it possible to get an anchor name with PHP?

For example, for this URL:

http://domain.com/#departments

How can I get the text "departments"?

Community
  • 1
  • 1
Ryan
  • 6,027
  • 16
  • 52
  • 89

1 Answers1

5

There is no way to get things after "#" in php, because this data is not provided to server, only url without data after "#", but if you are executing php script through JavaScript, you can Always split url into "#" and send the data as parameter or value of some hidden field.

Senad Meškin
  • 13,597
  • 4
  • 37
  • 55
  • 2
    "executing php script through JavaScript"? You very nearly got a +1 until I read that. Still, you're right that, if the source of the request -- be it a Javascript invoking XmlHttpRequest, or be it a human being -- reforms the URL then it will be easier to work with in this regard. Aw, hell, have the +1. – Lightness Races in Orbit Jun 01 '11 at 17:54
  • lol good one, I thought to write if you are executing AJAX request to server or XmlHttpRequest or ... in other browsers, then I thought if this can be the problem then he probably wont understand it so I have written JavaScript :) – Senad Meškin Jun 01 '11 at 17:57
  • and with executing I thought about sending request to server using JavaScript hahah lol me – Senad Meškin Jun 01 '11 at 17:58
  • That would have been less vague, yes. – Lightness Races in Orbit Jun 01 '11 at 23:11