469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Get content of URL after #

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
4 25054
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
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
There is a javascript method that can get the #value

using location.hash.slice(1)
Jul 17 '05 #4
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.

Similar topics

12 posts views Thread by jonathan.beckett | last post: by
10 posts views Thread by clintonG | last post: by
1 post views Thread by athirumurthi | last post: by
7 posts views Thread by xkeops | last post: by
9 posts views Thread by pbd22 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.