Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何显示任何包含整数值为_int()的变量?_Php_Variables_Return Value_Isinteger - Fatal编程技术网

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
返回一个字符串数组。见文件: