// Check if variable is int $id = "1"; if(!intval($id)){ throw new Exception("Not Int", 404); } else{ // this variable is int }