Check query string (PHP)

php, query-string

Solution

I'm not sure I fully understand what you want, but if you're not interested in the positioning of the parameters this should work:

if ( isset($_GET['var']) && count($_GET) > 1 ) {
    //do something if var and another parameter is given
}

Problem

I use a query string, for example `test.php?var=1`. How can I check if a user types anything after that, like another string... I try to redirect to index.php if any other string (query string) follows my `var` query string. Is it possible to check this? For example: ``` test.php?var=12134 (This is a good link..) test.php?a=23&var=123 (this is a bad link, redirect to index..) test.php?var=123132&a=23 (this is a bad link, redirect to index..) ```

Original source