The main problem is that the browser won't even send the request with the fragment part. Fragment parts are parsed directly in the browser. Therefore, it is accessible via JavaScript.
Anyway, you can useparse_url()to parse the URL into its parts, including the fragment part, but obviously that's not your case.
Simple test, visithttp://localhost:8000/hello?foo=bar#this-is-not-sent-to-server
The request received by the server does not contain what follows the # symbol - what follows the # symbol is just an anchor lookup on the client.
You can use javascript to find the anchor name used in the URL, for example:
If you already have a URL string containing a fragment, the parse_url() function in PHP can be used (http://codepad.org/BDqjtXix):
But I don't think PHP will receive the fragment information since it only exists on the client side.
The main problem is that the browser won't even send the request with the fragment part. Fragment parts are parsed directly in the browser. Therefore, it is accessible via JavaScript.
Anyway, you can useparse_url()to parse the URL into its parts, including the fragment part, but obviously that's not your case.