Is it possible to access anchors in querystring through PHP?

I have a page accessed via the url:

http://power-coder.net/Test/something.php?id=3#Page1

I know how to access the id parameter using $ _GET, however, do I have a way to access part # Page1? I looked at the $ _SERVER array, and does REQUEST_URI end in? Id = 3.

I know that I could also change # Page1 an additional parameter, for example & Page = 1, however there is a fair bit of code using the old type of URL that I would like to avoid re-writing, if at all possible.

Thanks for the help.

+4
source share
3 answers

No, there is no way. Part of the fragment (label after #) is not transmitted to the server.

The browser returns the document http://power-coder.net/Test/something.php?id=3 , and then go to the correct anchor (if any) in the document.

+6
source

Relevant specification text:

4.1. Fragment Id

When a URI is used to perform a search action on an identified resource, an optional fragment identifier separated from the URI by a cross-dash symbol ("#") consists of additional reference information that must be interpreted by the user agent after the search process has been successfully completed. Thus, this is not part of the URI, but is often used in conjunction with a URI.

+3
source

If someone is still looking for a solution.

Just put '&' before the anchor tag:

http://example.com/Test/something.php?id=3&#Page1

Tested in Chrome, Firefox, Safari and IE11

0
source

All Articles