is_int checks that the data type is an integer, but everything in $_GET will be a string. Therefore, it will always return false .
As a last resort, you can apply to an integer, and then check for! = 0.
$id = isset($_GET['id']) ? (int) $_GET['id'] : null; if (!$id) { // === 0 || === null header('HTTP/1.1 404 Not Found'); exit('404, page not found'); }
But a more reliable solution will include some type of input string checking / filtering, for example, the built-in PHP filter_input_array() .
(The edited post is in Oct / 13, as it still receives upvotes, and this was somewhat vaguely worded.)
Matthew
source share