is_int and GET or POST

Viewed 17586

Why does is_int always return false in the following situation?

echo $_GET['id']; //3
if(is_int($_GET['id']))
    echo 'int'; //not executed
10 Answers

How i fixed it:

$int_id = (int) $_GET["id"];

if((string)$int_id == $_GET["id"]) {
echo $_GET["id"];
}
Related