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 Link to comment https://forums.phpfreaks.com/topic/225526-parse_url-question/ 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. Link to comment https://forums.phpfreaks.com/topic/225526-parse_url-question/#findComment-1164595 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. Link to comment https://forums.phpfreaks.com/topic/225526-parse_url-question/#findComment-1164602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.