Here is my code:
<?php
$id = $_GET["id"];
if (is_int($id) === FALSE) {
header('HTTP/1.1 404 Not Found');
exit('404, page not found');
}
?>
It always enters inside the if.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
is_intchecks that the data type is an integer, but everything in$_GETwill be a string. Therefore, it will always returnfalse.In a pinch, you could cast to an integer and then check for != 0.
But a more robust solution would involve some type of input string validation / filtering, like PHP’s built-in
filter_input_array().(Edited post on Oct/13 since it is still receiving upvotes and it was somewhat confusingly worded.)