Page 1 of 1

URI hash.

Posted: Wed Apr 18, 2007 6:45 pm
by JellyFish
It's simple. How can I return the URL's hash in php, like you can do in javascript via the 'window.location.hash' object?

In other words what's the "equivalent"?

Posted: Wed Apr 18, 2007 6:55 pm
by Weirdan
Is it ever sent to server actually?

Posted: Wed Apr 18, 2007 7:03 pm
by JellyFish
Not sure what you mean. If you mean is a hash always sent to the server through the URL, then that'd be a "no". How ever, I'll just do an if statement checking to see if the hash been sent.

Posted: Wed Apr 18, 2007 7:16 pm
by Weirdan
Although browsers usually do not send the hash part of the URL to the server, it would available in the $_SERVER['REQUEST_URI'] if it was sent.

Posted: Wed Apr 18, 2007 7:54 pm
by JellyFish
I don't understand. I'm not trying to be stupid... :?

Posted: Wed Apr 18, 2007 9:24 pm
by feyd
There is no equivalent to location.hash in PHP. You will have to parse the URI yourself.

Posted: Thu Apr 19, 2007 1:30 am
by Chris Corbyn
See the function http://www.php.net/parse_url

You'll need to get the URL from $_SERVER first though.

Posted: Thu Apr 19, 2007 4:15 pm
by JellyFish
Okay cool. Thanks guys. :D