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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.