function checkString($subject){ $pattern = "[^_a-zA-Z0-9-]"; if(ereg($pattern, $subject, $regs)){ return false; } else { return true; } } $num = $_GET['num']; if($num == "" || checkString($num)== false){ $num = "2"; } ?>