dsbpac Posted October 6, 2016 Share Posted October 6, 2016 Can someone please help me!! How can I get the value in an link like <a href="#first">Link</a> I need to get first in an variable. I have search an search but I can't find any help. I know I can get it if i pass it in the URL name but the way the css is coded. I need to get the value like it is. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/302290-get-value-posted-in-url/ Share on other sites More sharing options...
Jacques1 Posted October 6, 2016 Share Posted October 6, 2016 Get the value where? In PHP? That's not possible, because the URL fragment (the part after #) is never sent to the server. It's purely client-side. It might be a good idea if you explain what exactly you're trying to do. I mean the broader picture. Quote Link to comment https://forums.phpfreaks.com/topic/302290-get-value-posted-in-url/#findComment-1538088 Share on other sites More sharing options...
cyberRobot Posted October 7, 2016 Share Posted October 7, 2016 If you are looking to pass variables through anchor tags, you use a format like this: <a href="?myVar=hello">Link</a> Note the question mark before the variable named "myVar". When you click the link, the variable is passed to PHP and can be retrieved using $_GET['myVar']. Here's a quick code sample that you could use: <?php if(isset($_GET['myVar'])) { echo $_GET['myVar']; } ?> <div><a href="?myVar=hello">Link</a></div> 1 Quote Link to comment https://forums.phpfreaks.com/topic/302290-get-value-posted-in-url/#findComment-1538104 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.