'check whether ANY variable of type $_GET exists [closed]
I know that I can check whether a particular $_GET variable exists with
isset($_GET['foo'])
But how can I check whether any $_GET variable exists? I thought that it would be as simple as
isset($_GET)
But that does not work. It always evaluates as true, even if there are no parameters in the URL.
Thanks in advance for your help!
Solution 1:[1]
You can use count:
// if get is empty
count($_GET) > 0 // false
// if get contains some key value pairs
count($_GET) > 0 // true
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Maik Lowrey |
