PHP手册-类型

来源:互联网 发布:pl sql develop 编辑:程序博客网 时间:2024/05/16 12:56
如果只是想得到一个易读懂的类型的表达方式用于调试,用 gettype()。要查看某个类型,不要用 gettype(),而用 is_type 函数。以下是一些范例:
$a_bool = TRUE;   // a boolean$a_str  = "foo";  // a string$a_str2 = 'foo';  // a string$an_int = 12;     // an integerecho gettype($a_bool); // prints out:  booleanecho gettype($a_str);  // prints out:  string// If this is an integer, increment it by fourif (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";}

原创粉丝点击