thefollower Posted September 12, 2008 Share Posted September 12, 2008 When can this ever be used in php? Because when i input 10 in a input box im assuming php takes it as a string of two chars which is 1 and 0 rather than the number 10 which would explain why my is_int() function check fails when it checks if the input is an integer... so what can i do to check the number is a nice integer? This is what i put: <?php $Price = mysql_real_escape_string($_POST['Price']); If($Price < 1 OR !(is_numeric($Price)) OR !(is_numeric($Tokens2)) OR !(is_int($Price))){ ?> Price must be greater than zero!</span> <br> <a href="test.php">Back</a> <? } ?> Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/ Share on other sites More sharing options...
thebadbad Posted September 12, 2008 Share Posted September 12, 2008 Use ctype_digit() instead. Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/#findComment-639868 Share on other sites More sharing options...
thefollower Posted September 12, 2008 Author Share Posted September 12, 2008 Thank you Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/#findComment-639874 Share on other sites More sharing options...
Demonic Posted September 12, 2008 Share Posted September 12, 2008 Note you should type cast the var since it only accepts strings. ctype_digit( string $int ) Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/#findComment-639876 Share on other sites More sharing options...
thebadbad Posted September 12, 2008 Share Posted September 12, 2008 Note you should type cast the var since it only accepts strings. ctype_digit( string $int ) In his case it will always be a string, but sure, to stay out of trouble later on. Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/#findComment-639878 Share on other sites More sharing options...
Mchl Posted September 12, 2008 Share Posted September 12, 2008 ctype_digit( (string)$int ); Link to comment https://forums.phpfreaks.com/topic/123952-solved-is_int-function/#findComment-639879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.