Php 如何显示任何包含整数值为_int()的变量?
我有以下代码:Php 如何显示任何包含整数值为_int()的变量?,php,variables,return-value,isinteger,Php,Variables,Return Value,Isinteger,我有以下代码: $showCountSql = "select cad_count from counteraccountdtl WHERE cad_userid =".$_SESSION['UID']." LIMIT 1"; $showCountresult = mysql_query($showCountSql); $showCountrow = mysql_fetch_array($showCountresult); $newCount = $showCountr
$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";
我从MySql获取的值为“cad_count integer(5)”,然后检查该值是否为整数,并相应地显示“value not integer”。有什么问题吗?使用或。这些函数测试给定变量是否是数字的有效表示形式或仅包含数字
测试变量的类型是否为int
,mysql_fetch*函数是否以字符串形式返回整数。是数值()
更适合您。要使is_int()起作用,必须从旧的值生成int值
$var = intval($var);
您可以始终使用
var\u dump($newCount)
查看变量的类型以及内容。为确保答案的完整性,mysql\u fetch\u array
返回一个字符串数组。见文件: