hazz995 Posted November 19, 2009 Share Posted November 19, 2009 Wondering how do I create a link that changes a variable in php when clicked instead of actually going anywhere, still new to PHP Quote Link to comment https://forums.phpfreaks.com/topic/182138-solved-linking-variable/ Share on other sites More sharing options...
Alex Posted November 19, 2009 Share Posted November 19, 2009 You can't exactly do that in PHP. You can in JavaScript, but if that's not what you're looking for you can use the $_GET superglobal with similar functionality. Example: <?php $var = isset($_GET['var']) ? $_GET['var'] : 'Not set'; echo '$var is: ' . $var; ?> <a href="?var=somethingelse">Click!</a> Quote Link to comment https://forums.phpfreaks.com/topic/182138-solved-linking-variable/#findComment-960928 Share on other sites More sharing options...
hazz995 Posted November 19, 2009 Author Share Posted November 19, 2009 You can't exactly do that in PHP. You can in JavaScript, but if that's not what you're looking for you can use the $_GET superglobal with similar functionality. Example: <?php $var = isset($_GET['var']) ? $_GET['var'] : 'Not set'; echo '$var is: ' . $var; ?> <a href="?var=somethingelse">Click!</a> Thanks a lot, I got the result I wanted. Quote Link to comment https://forums.phpfreaks.com/topic/182138-solved-linking-variable/#findComment-960938 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.