Doqrs Posted April 21, 2006 Share Posted April 21, 2006 Hello,say i have a weblocation [a href=\"http://someurl.com/index.php#here\" target=\"_blank\"]http://someurl.com/index.php#here[/a], how would i get the information after the # sign, php_self only returns index.php. I am in need of the 'here' text. Thanks in advance, its hard doing a search on a pound sign :-p Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted April 21, 2006 Share Posted April 21, 2006 [!--quoteo(post=367060:date=Apr 21 2006, 01:53 AM:name=Doqrs)--][div class=\'quotetop\']QUOTE(Doqrs @ Apr 21 2006, 01:53 AM) [snapback]367060[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hello,say i have a weblocation [a href=\"http://someurl.com/index.php#here\" target=\"_blank\"]http://someurl.com/index.php#here[/a], how would i get the information after the # sign, php_self only returns index.php. I am in need of the 'here' text. Thanks in advance, its hard doing a search on a pound sign :-p[/quote]hmm i tried this with a couple of files and a phpinfo(), but couldn't actually find anything. i'd probably say then it's not possible to do it this way.however, there maybe alternative ways of getting your desired effect, depending on what youre trying to achieve? Quote Link to comment Share on other sites More sharing options...
Doqrs Posted April 21, 2006 Author Share Posted April 21, 2006 well im using ajax to load the content of my page, and am changing the document.href in javascript after the content loads ( i want to be able to copy and paste the link to be able to hotlink to a certain area). Anyways all the stuff is done with javascript but i wanted to be able to get the variables into php without having to manage cookies. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 21, 2006 Share Posted April 21, 2006 This will help you on your way. I found this when trying to do the same thing.If you set a variable to contain the value of selfURL(); you will then be able to use substr to get whatever is after the #.[code]<?phpfunction selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];}function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2));} ?>[/code] Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted April 21, 2006 Share Posted April 21, 2006 [!--quoteo(post=367170:date=Apr 21 2006, 01:10 PM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 21 2006, 01:10 PM) [snapback]367170[/snapback][/div][div class=\'quotemain\'][!--quotec--]This will help you on your way. I found this when trying to do the same thing.If you set a variable to contain the value of selfURL(); you will then be able to use substr to get whatever is after the #.[code]<?phpfunction selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];}function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2));} ?>[/code][/quote]but all of your methods here containt variables from the $_SERVER array, which i checked whilst looking through the phpinfo(). notably, $_SERVER['REQUEST_URI'] which i would have expected to hold the result - didnt work there, either. Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 21, 2006 Share Posted April 21, 2006 just curious, but why use the # instead of the ? anyway Quote Link to comment Share on other sites More sharing options...
Doqrs Posted April 21, 2006 Author Share Posted April 21, 2006 [!--quoteo(post=367214:date=Apr 21 2006, 11:19 AM:name=wisewood)--][div class=\'quotetop\']QUOTE(wisewood @ Apr 21 2006, 11:19 AM) [snapback]367214[/snapback][/div][div class=\'quotemain\'][!--quotec--]just curious, but why use the # instead of the ? anyway[/quote]All of the pages load via ajax, and i dont want the page to refresh because there is a flash audio player in the top. 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.