一般PHP的数据类型不是由程序员定义 PHP会根据它的值自动匹配类型
四种标量类型:
两种复合类型:
最后是两种特殊类型:
var_dump(): 查看某个表达式的值和类型 。
gettype() 如果只是想得到一个易读懂的类型的表达方式用于调试,用
is_type() 判断类型
<?php $a_bool = TRUE; // a boolean $a_str = "foo"; // a string $a_str2 = ‘foo‘; // a string $an_int = 12; // an integer echo gettype($a_bool); // prints out: boolean echo gettype($a_str); // prints out: string // If this is an integer, increment it by four if (is_int($an_int)) { $an_int += 4; } // If $bool is a string, print it out // (does not print out anything) if (is_string($a_bool)) { echo "String: $a_bool"; } ?>
查看某个类型
原文:http://www.cnblogs.com/YangJM/p/7072386.html