Jump to content

Recommended Posts

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
[!--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?
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.
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]
<?php

function 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]
[!--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]
<?php

function 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.
[!--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.
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.