Jump to content

parse_url question.


Vander

Recommended Posts

Does anyone know how I retrive the "fragment" of a URL from the current page being viewed?

 

This is what I'm using just now.

<php
$URI = parse_url("http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
echo "<pre>";
print_r($_URI);
echo "</pre>";

 

This is what it's returning.

Array
(
    [scheme] => http
    [host] => localhost
    [path] => /test.php
)

 

And this is the URI I'm using.

http://localhost/test.php#fragment

 

Thanks in advance,

Alan

Link to comment
https://forums.phpfreaks.com/topic/225526-parse_url-question/
Share on other sites

I don't believe the browser will pass the fragment to the server (it doesn't need it), so the server normally won't get that information. So even if you hit http://localhost/test.php#fragment the server will only be passed http://localhost/test.php, while the browser will handle scrolling the page to the right place.

 

If you REALLY need the fragment, you might get it with Javascript.

Link to comment
https://forums.phpfreaks.com/topic/225526-parse_url-question/#findComment-1164595
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.