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. 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... 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.) 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. 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
Archived
This topic is now archived and is closed to further replies.