DavidGS Posted December 28, 2007 Share Posted December 28, 2007 I know this is a rather trivial question, but how do I go about setting the value of a variable through a URL? Like, say you had a page which has "tabs" and for each tab you want to display different content. To make sure the user sees the right tab, you would use something like http://example.com/index.php?tab=1 When I try to set the value of a variable that way it doesn't return anything. print "$pageid"; with the URL http://localhost/index.php?pageid=1 Nothing is printed because pageid doesn't have a value. But if I try defining the variable in the script: $pageid = 1; It returns whatever value I defined it with instead. What is right way of using variables in your URL? Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/ Share on other sites More sharing options...
Northern Flame Posted December 28, 2007 Share Posted December 28, 2007 $pageid = $_GET['tab']; echo $pageid; Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424503 Share on other sites More sharing options...
DavidGS Posted December 28, 2007 Author Share Posted December 28, 2007 $pageid = $_GET['tab']; echo $pageid; Thank you very much. Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424505 Share on other sites More sharing options...
Northern Flame Posted December 28, 2007 Share Posted December 28, 2007 you're welcome Link to comment https://forums.phpfreaks.com/topic/83442-solved-setting-variable-values-through-the-url/#findComment-424506 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.