+1  A: 

I would use

if (isset($_GET['ID']) && ($_GET['ID']+0>0)) {
   echo (int)$_GET['ID']
}

with a casting to integer (int). If the value must be an integer.

powtac
In this case you have to:1) always use casting2) always test, if the variable is set (isset($_GET['ID']))
oneee
Yes, and there will be no shorter way to achieve this. If the variable is not set, the second condition of the expression will not be executed. But only if its sure that the value has to be an integer.
powtac
Shorter way with class from option 1: echo (int)WebApp::_GET('ID');
oneee
But you didn't checked if the var is set. You would get "0" even if there was no value provided!
powtac
A: 

i'd use a Request class that encapsulates all Php "superglobals" and provides methods like "param()", "numParam()", "arrayParam()" and so on.

$req = new Request();
$user_id = $req->numParam('id');
 // user_id is guaranteed to be a valid integer or 0
stereofrog
This is very similar to my first option. I used static method, so I don't have to create new class every time I need to use it.I like your approch with "numParam", "arrayParam", etc...
oneee