superkingkong Posted April 5, 2009 Share Posted April 5, 2009 Hi guys, how can I get certail value from a uri and do if statement? eg, url: http://geocities.com/~myusername/file.php?1 url: http://geocities.com/~myusername/file.php?2 url: http://geocities.com/~myusername/file.php?3 if ($_SERVER['REQUEST_URI'] == 1) do this elseif == 2 do this else do this I'm a newbie in php, appreciate if you could help me, thanks. Quote Link to comment https://forums.phpfreaks.com/topic/152684-how-to-get-certail-value-from-uri-and-do-if-statement/ Share on other sites More sharing options...
charleshill Posted April 5, 2009 Share Posted April 5, 2009 http://yoursite.com/script.php?1 For the above URL, you could just do isset($_GET['1']) ... or isset($_GET[1]) might work... I don't use numbers as get variables in URLs. Strings work fine in this manner though... Quote Link to comment https://forums.phpfreaks.com/topic/152684-how-to-get-certail-value-from-uri-and-do-if-statement/#findComment-801809 Share on other sites More sharing options...
corbin Posted April 5, 2009 Share Posted April 5, 2009 parseurl Might work for you if what charleshill said doesn't work. (What he said should work, but maybe it's not as simple as the example you gave or something.) Quote Link to comment https://forums.phpfreaks.com/topic/152684-how-to-get-certail-value-from-uri-and-do-if-statement/#findComment-801814 Share on other sites More sharing options...
superkingkong Posted April 5, 2009 Author Share Posted April 5, 2009 thanks... it works btw, why you don't use numbers as get variables in URLs? i did a search and manage to find another function, query_string. is it the same or less reliable than get? thanks. Quote Link to comment https://forums.phpfreaks.com/topic/152684-how-to-get-certail-value-from-uri-and-do-if-statement/#findComment-801834 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.