Connecting Tech Pros Worldwide Forums | Help | Site Map

Get content of URL after #

Tim Tyler
Guest
 
Posts: n/a
#1: Jul 17 '05
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/ tim@tt1lock.org Remove lock to reply.

Andy Hassall
Guest
 
Posts: n/a
#2: Jul 17 '05

re: Get content of URL after #


On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <tim@tt1lock.org> wrote:
[color=blue]
>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...[/color]

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

--
Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Tim Tyler
Guest
 
Posts: n/a
#3: Jul 17 '05

re: Get content of URL after #


Andy Hassall <andy@andyh.co.uk> wrote or quoted:[color=blue]
> On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <tim@tt1lock.org> wrote:[/color]
[color=blue][color=green]
>>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")? [...][/color]
>
> You can't; it's not passed to the server.[/color]

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/ tim@tt1lock.org Remove lock to reply.
Craig Keightley
Guest
 
Posts: n/a
#4: Jul 17 '05

re: Get content of URL after #


There is a javascript method that can get the #value

using location.hash.slice(1)


BKDotCom
Guest
 
Posts: n/a
#5: Jul 17 '05

re: Get content of URL after #


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

Tim Tyler <tim@tt1lock.org> wrote in message news:<HMntEK.6ty@bath.ac.uk>...[color=blue]
> 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...[/color]
Closed Thread