PHP Data Type
PHP supports eight primitive types ).
Four scalar types:
String (string)
Integer)
Float (float, also double)
Boolean (boolean)
Two composite types:
Array)
Object)
Two special types:
Resource)
NULL)View variable types
The gettype () function allows you to conveniently view the type of a variable:
<? Php $ var_bool = TRUE; // a boolean $ var_str = "foo"; // a string $ var_int = 12; // an integerecho gettype ($ var_bool ); // output booleanecho gettype ($ var_str); // output stringecho gettype ($ var_int); // output integer?> It indicates that for historical reasons, if float data is returned, the gettype () function returns double instead of float.
To view the value and type of an expression, use the var_dump () function.Judge variable type
To determine the next logical action by determining the variable type, use the is_type series functions instead of gettype:
<? Php $ var_int = 12; // if $ var_int is of the int type, add if (is_int ($ var_int) {$ var_int = $ var_int + 4;} echo $ var_int; // output 16?>