Connecting Tech Pros Worldwide Help | Site Map

Get content of URL after #

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:30 AM
Tim Tyler
Guest
 
Posts: n/a
Default 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/ tim@tt1lock.org Remove lock to reply.

  #2  
Old July 17th, 2005, 12:30 AM
Andy Hassall
Guest
 
Posts: n/a
Default 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)
  #3  
Old July 17th, 2005, 12:30 AM
Tim Tyler
Guest
 
Posts: n/a
Default 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.
  #4  
Old July 17th, 2005, 12:31 AM
Craig Keightley
Guest
 
Posts: n/a
Default Re: Get content of URL after #

There is a javascript method that can get the #value

using location.hash.slice(1)


  #5  
Old July 17th, 2005, 12:32 AM
BKDotCom
Guest
 
Posts: n/a
Default 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]
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.