colourcolourcolourcolourcolourcolourcolour
Forgot my colour selection

Using PHP isset To Detect An Empty GET Request

Here’s something I learnt a while back, about how to detect if there is a ?foo after the page URL, even if that GET request is empty (without the =bar) bit. Try it on my “Random Post” button, you will find it adds a ?r after the post URL you are sent to, so the page knows to add an ID that makes the button highlighted.

So, to detect it:

if (isset($_GET['foo'])) echo('Yeah, foo is set');

This would work on something like http://www.example.com/index.php?foo, and avoids an unnecessary ?foo=yes or something to indicate that foo is true. Neat and tidy :-)

Posted on June 6th, 2008. Filed under Awesome, Code, and tagged with .

Leave a Comment

Make yourself heard

Montly Post Archives

Posts from previous months