Perad Posted March 14, 2008 Share Posted March 14, 2008 $poll = $_GET['poll']; $user_id = $_GET['user']; if (is_int($poll)) { $poll = 13 The if code does not work. If I change the code to (is_int(13)) Then it works.. Any ideas why this is? Link to comment https://forums.phpfreaks.com/topic/96161-is_int-odities/ Share on other sites More sharing options...
micah1701 Posted March 14, 2008 Share Posted March 14, 2008 try using is_numeric instead. sometimes the php considers your number a string and not an integer, depending on how it was assigned to the variable Link to comment https://forums.phpfreaks.com/topic/96161-is_int-odities/#findComment-492236 Share on other sites More sharing options...
accident Posted March 14, 2008 Share Posted March 14, 2008 I would either type cast it with (int) or use ctype_digit if validating user input personally Link to comment https://forums.phpfreaks.com/topic/96161-is_int-odities/#findComment-492271 Share on other sites More sharing options...
thebadbad Posted March 14, 2008 Share Posted March 14, 2008 GET and POST values are always strings, therefore is_int fails. Also, is_numeric will accept scientific and hexadecimal notation. If you only want to allow integers, use ctype_digit. Link to comment https://forums.phpfreaks.com/topic/96161-is_int-odities/#findComment-492348 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.