To check if a string input is a positive integer, i always use the function ctype_digit. This is much easier to understand and faster than a regular expression.
if (isset($_GET['p']) && ctype_digit($_GET['p']))
{
// the get input contains a positive number and is safe
}