tags:

views:

528

answers:

3

http://domain.com/site/gallery/1#photo45

How to read value after the # sign (photo45)?

PS: What is the English word for the # sign?

A: 

You can't get the text after the hash mark. It is not sent to the server in a request.

Ignacio Vazquez-Abrams
+3  A: 

That part is called "fragment" and you can get it in this way:

$url=parse_url("http://domain.com/site/gallery/1#photo45 ");
echo $url["fragment"]; //This variable contains the fragment
mck89
+6  A: 

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.

sfussenegger
Is there way to get this value using javascript? I think that would also solve my problem
ile
`alert(window.location.hash);`
sfussenegger