471,825 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,825 software developers and data experts.

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 25136
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
NeoPa
reply views Thread by NeoPa | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.