How can i select the fragment after the ‘#’ symbol in my URL using PHP?
The result that i want is "photo45".
This is an example URL:
http://example.com/site/gallery/1#photo45
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to get the value after the hash mark or anchor as shown in a user’s browser: This isn’t possible with “standard” HTTP as this value is never sent to the server (hence it won’t be available in
$_SERVER["REQUEST_URI"]or similar predefined variables). You would need some sort of JavaScript magic on the client side, e.g. to include this value as a POST parameter.If it’s only about parsing a known URL from whatever source, the answer by mck89 is perfectly fine though.