Page 1 of 1

URL with fragment?

Posted: Tue Dec 12, 2006 3:19 am
by rmccue
Is there a PHP variable which contains either the whole URL including the fragment or a variable that holds the fragment?
Fragment: The part of the URL after the # eg:
http://blah.com/page.php#faq
----------------------------------^^
Thanks.

Posted: Tue Dec 12, 2006 3:23 am
by matthijs

Posted: Tue Dec 12, 2006 3:32 am
by rmccue
I thought about that, but you need to have the URL already. I'm looking for something that takes the current script's URL and gets the fragment.

Posted: Tue Dec 12, 2006 3:43 am
by matthijs
Ok. The current script's url should be in the $_SERVER variables http://nl2.php.net/manual/en/reserved.variables.php
I think you'd want 'REQUEST_URI'
and after that use the parse_url function to get the fragment.

Posted: Tue Dec 12, 2006 3:50 am
by rmccue
Nope.
It's not in there either.
Note: I'm using print_r on it:

Code: Select all

<?php
$og = parse_url($_SERVER['REQUEST_URI']);
print_r($og);
?>

Posted: Tue Dec 12, 2006 5:00 am
by matthijs
Indeed. None of the $_SERVER[''] variables contains the fragment. At the moment I wouldn't know were else to look (without reading the complete manual.. :wink: ), I'm sorry.

Posted: Tue Dec 12, 2006 5:08 am
by rmccue
Damn.
I'll just have to use Javascript to get it.