Heim >Backend-Entwicklung >PHP-Tutorial >PHP数据类型判断函数总结
PHP数据类型判断函数总结
<?php<br />//判断数组 <br />$colors = array("red", "blue", "green"); <br />if(is_array($colors)) <br />{ <br />print("colors is an array"."<br>"); <br />} <br />//双精度数判断 <br />$Temperature = 15.23; <br />if(is_double($Temperature)) <br />{ <br />print("Temperature is a double"."<br>"); <br />} <br />//整数判断 <br />$PageCount = 2234; <br />if(is_integer($PageCount)) <br />{ <br />print("$PageCount is an integer"."<br>"); <br />} <br />//对象判断 <br />class widget <br />{ <br />var $name; <br />var $length; <br />} <br />$thing = new widget; <br />if(is_object($thing)) <br />{ <br />print("thing is an object"."<br>"); <br />} <br />//字符判断 <br />$Greeting = "Hello"; <br />if(is_string($Greeting)) <br />{ <br />print("Greeting is a string"."<br>"); <br />} <br />?>