开发者

how can display any variable contant integer value is_int()?

开发者 https://www.devze.com 2023-04-04 12:33 出处:网络
I have this code: $showCountSql= \"select cad_count from counteraccountdtl WHERE cad_userid =\".$_SESSION[\'UID\'].\" LIMIT 1\";

I have this code:

$showCountSql    = "select cad_count from counteraccountdtl WHERE cad_userid =".$_SESSION['UID']." LIMIT 1";
$showCountresult = mysql_query($showCountSql);
$showCountrow    = mysql_fetch_array($showCountresult);
$newCount        = $showCountrow[cad_count];

if(is_int($newCount))
 echo "Value  is Integer";
else
 echo "Value not Integer";

I am fetching the value from MySql as "c开发者_开发技巧ad_count integer(5)", then I check whether this value is an integer or not and show the "Value not Integer" accordingly. What's wrong in it?


Use is_numeric() or ctype_digit(). These functions test if the given variable is a valid representation of a number or contains only digits.

is_int tests if the variable's type is int, and mysql_fetch* functions return integers as strings.


is_numeric() is better for you. To make is_int() work, you have to make int value from old one

$var = intval($var);
0

精彩评论

暂无评论...
验证码 换一张
取 消