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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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. |
|
|||
|
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) |
|
|||
|
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. |
|
|||
|
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... |