How to check if $_GET is empty?

Vamsi Krishna B picture Vamsi Krishna B · Aug 4, 2010 · Viewed 158k times · Source

How to check if $_GET is empty?

Answer

NikiC picture NikiC · Aug 4, 2010

You said it yourself, check that it's empty:

if (empty($_GET)) {
    // no data passed by get
}

See, PHP is so straightforward. You may simply write, what you think ;)

This method is quite secure. !$_GET could give you an undefined variable E_NOTICE if $_GET was unset (not probable, but possible).