0

I'm working on a functionality that requires the php script to know the html anchor name a page has been loaded with. I'm finding such of dearth of information on the topic I'm not even sure if I'm using the right nomenclature.

Basically I would have someone landing on a page using an internal anchor. Something like www.mypage.com/index.php#my_place_in_page or www.mypage.com/index.php?param=42#my_place_in_page. In this case my goal would be to get my_place_in_page into my script somehow.

I've gone through the whole list of things that $_SERVER can get me, and it doesn't seem to be there. $_SERVER['REQUEST_URI'] will return www.mypage.com/index.php or www.mypage.com/index.php?param=42, but always cuts off after the hash.

Is there any way to get the anchor name? Or is the reason I can't find any references to this because it's just not something that php does.

Thanks for help or insight that anyone can offer.

Sean F
  • 11
  • Add the anchor name as a CGI parameter on the page with the link? – Dave S Oct 09 '22 at 01:51
  • 1
    While the value isn't available to PHP, JavaScript can grab it and send it to the server via an AJAX request. More conversation on the topic can be found here: https://stackoverflow.com/a/2317523/2585216 – verl Oct 09 '22 at 01:51

0 Answers0