PHP - Input Variables from URL

I wanted to be able to generate a small little bit of content based on a variable the user sets. I could have created a small form, but in this case it was easier to pass the variable in a link based on a choice the user selected. Here is a really simple example of passing a variable via URL string to my php page.

if ($_GET["id"]) {
  $programID = $_GET["id"];
} else {
  $programID = "not specified";
echo "Program ID is $programID \n";

It's always important to have cases / defensive / debugging code. Keeps the logs cleaner, makes items easier to fix/debug, and it is just good clean living.

WARNING - I'm not an expert coder/developer, just posting little bits I learn as I go.

UPDATED - Thanks to @j_angliss for providing the more elegant solution. If 'id' in this case is legitimately "0" (zero), then the evaluation would not execute and be treated as false (aka "0"). Try this code instead...

if (array_key_exists('if',$_GET)) {