By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,642 Members | 1,696 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,642 IT Pros & Developers. It's quick & easy.

Get content of URL after #

P: n/a
A simple question:

If my PHP page is referenced thus: foo.php#bar

....what's the best way of getting the contents of the URL
after the hash - as a string ("bar")?

Should I get the URL, look for the "#" and then use
substring()?

I'd prefer something like:

$H = $_GET['#']; // reaching...
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <ti*@tt1lock.org> wrote:
A simple question:

If my PHP page is referenced thus: foo.php#bar

...what's the best way of getting the contents of the URL
after the hash - as a string ("bar")?

Should I get the URL, look for the "#" and then use
substring()?

I'd prefer something like:

$H = $_GET['#']; // reaching...


You can't; it's not passed to the server.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2

P: n/a
Andy Hassall <an**@andyh.co.uk> wrote or quoted:
On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <ti*@tt1lock.org> wrote:

A simple question:

If my PHP page is referenced thus: foo.php#bar

...what's the best way of getting the contents of the URL
after the hash - as a string ("bar")? [...]


You can't; it's not passed to the server.


So it isn't ;-)

On reflection, $_SERVER['REQUEST_URI']; gives me close enough to
what I am after. Thanks for the "#" advice.
--
__________
|im |yler http://timtyler.org/ ti*@tt1lock.org Remove lock to reply.
Jul 17 '05 #3

P: n/a
There is a javascript method that can get the #value

using location.hash.slice(1)
Jul 17 '05 #4

P: n/a
try parse_url();
http://www.php.net/manual/en/function.parse-url.php

Tim Tyler <ti*@tt1lock.org> wrote in message news:<HM********@bath.ac.uk>...
A simple question:

If my PHP page is referenced thus: foo.php#bar

...what's the best way of getting the contents of the URL
after the hash - as a string ("bar")?

Should I get the URL, look for the "#" and then use
substring()?

I'd prefer something like:

$H = $_GET['#']; // reaching...

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.