PHP的几个常用数字判断函数代码
程序员文章站
2022-05-24 13:46:00
复制代码 代码如下: 常用的数值判断函数
<html>
<head>
<title>常用的数值判断函数</title>
</head>
<body>
<?
//判断数组
$colors = array("red", "blue", "green");
if(is_array($colors))
{
print("colors is an array"."<br>");
}
//双精度数判断
$temperature = 15.23;
if(is_double($temperature))
{
print("temperature is a double"."<br>");
}
//整数判断
$pagecount = 2234;
if(is_integer($pagecount))
{
print("$pagecount is an integer"."<br>");
}
//对象判断
class widget
{
var $name;
var $length;
}
$thing = new widget;
if(is_object($thing))
{
print("thing is an object"."<br>");
}
//字符判断
$greeting = "hello";
if(is_string($greeting))
{
print("greeting is a string"."<br>");
}
?>
</body>
</html>
复制代码 代码如下:
<html>
<head>
<title>常用的数值判断函数</title>
</head>
<body>
<?
//判断数组
$colors = array("red", "blue", "green");
if(is_array($colors))
{
print("colors is an array"."<br>");
}
//双精度数判断
$temperature = 15.23;
if(is_double($temperature))
{
print("temperature is a double"."<br>");
}
//整数判断
$pagecount = 2234;
if(is_integer($pagecount))
{
print("$pagecount is an integer"."<br>");
}
//对象判断
class widget
{
var $name;
var $length;
}
$thing = new widget;
if(is_object($thing))
{
print("thing is an object"."<br>");
}
//字符判断
$greeting = "hello";
if(is_string($greeting))
{
print("greeting is a string"."<br>");
}
?>
</body>
</html>