Rifts Posted February 19, 2012 Share Posted February 19, 2012 Hey guys, It's been awhile since I've coded in PHP and I can not for the life of me remember how to do this. Say I have http://www.example.com/search.php?name=joe&size=small What the PHP code to grab the ?name=joe&size=small part? thanks Link to comment https://forums.phpfreaks.com/topic/257322-php-get-url-info/ Share on other sites More sharing options...
PaulRyan Posted February 19, 2012 Share Posted February 19, 2012 You'd probably want to use $_GET like this: <?PHP $name = $_GET['name']; //### Will now be "joe" $size = $_GET['size']; //### Will now be "small" echo 'Name: ' . $name . ' <br>'; echo 'Size: ' . $size; ?> Of course you will have to check to make sure the query paramter exists using isset. Regards, PaulRyan. Link to comment https://forums.phpfreaks.com/topic/257322-php-get-url-info/#findComment-1318974 Share on other sites More sharing options...
requinix Posted February 19, 2012 Share Posted February 19, 2012 A couple more answers since the question is a bit ambiguous: - if that URL is in a string then use parse_url - the whole query string (without the question mark) is in $_SERVER["QUERY_STRING"] Link to comment https://forums.phpfreaks.com/topic/257322-php-get-url-info/#findComment-1318976 Share on other sites More sharing options...
Rifts Posted February 19, 2012 Author Share Posted February 19, 2012 perfect thanks Link to comment https://forums.phpfreaks.com/topic/257322-php-get-url-info/#findComment-1318978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.