is_int()是PHP中的內置函數。 is_int()函數用於測試指定變量的類型是否為整數。
用法:
boolean is_int($variable_name) Parameter:this function contains a single parameter $variable_name:the variable we want to check. Return value:it is a boolean function so returns T RUE when $variable_name is an integer, otherwise FALSE.
<?php
$variable_name1 = 56;
$variable_name2 = "xyz";
if (is_int($variable_name1))
{
echo "$variable_name1 is Integer \n" ;
}
else
{
echo "$variable_name1 is not an Integer \n" ;
}
if (is_int($variable_name2))
{
echo "$variable_name2 is Integer \n" ;
}
else
{
echo "$variable_name2 is not Integer \n" ;
}
?>
輸出:
56 is Integer xyz is not Integer
參考:http://php.net/manual/en/function.is-int.php
注:本文由純淨天空篩選整理自sid4321大神的英文原創作品 PHP | is_int()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。