Get content of URL after #

This is a discussion on Get content of URL after # within the PHP Language forums, part of the PHP Programming Forums category; A simple question: If my PHP page is referenced thus: foo.php#bar ....what's the best way of getting ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-12-2003
Tim Tyler
 
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.
Reply With Quote
  #2 (permalink)  
Old 10-12-2003
Andy Hassall
 
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:

>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 (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Reply With Quote
  #3 (permalink)  
Old 10-12-2003
Tim Tyler
 
Posts: n/a
Default Re: Get content of URL after #

Andy Hassall <andy@andyh.co.uk> wrote or quoted:
> On Sun, 12 Oct 2003 19:42:20 GMT, Tim Tyler <tim@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/ tim@tt1lock.org Remove lock to reply.
Reply With Quote
  #4 (permalink)  
Old 10-13-2003
Craig Keightley
 
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)


Reply With Quote
  #5 (permalink)  
Old 10-14-2003
BKDotCom
 
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>...
> 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...

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:37 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0