Vander Posted January 24, 2011 Share Posted January 24, 2011 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 Quote Link to comment Share on other sites More sharing options...
mikecampbell Posted January 24, 2011 Share Posted January 24, 2011 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. Quote Link to comment Share on other sites More sharing options...
Vander Posted January 24, 2011 Author Share Posted January 24, 2011 Ok, well thankfully I had a javascript backup plan, I just prefer to use PHP if possible, thanks anyways, Mike. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.