URL with fragment?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rmccue
Forum Commoner
Posts: 27
Joined: Thu Oct 05, 2006 12:47 am
Location: Gold Coast, Australia

URL with fragment?

Post 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.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

rmccue
Forum Commoner
Posts: 27
Joined: Thu Oct 05, 2006 12:47 am
Location: Gold Coast, Australia

Post 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.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post 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.
rmccue
Forum Commoner
Posts: 27
Joined: Thu Oct 05, 2006 12:47 am
Location: Gold Coast, Australia

Post 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);
?>
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post 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.
rmccue
Forum Commoner
Posts: 27
Joined: Thu Oct 05, 2006 12:47 am
Location: Gold Coast, Australia

Post by rmccue »

Damn.
I'll just have to use Javascript to get it.
Post Reply