PHP supports 8 types of raw data.
Four scalar types: Boolean (Boolean), Integer (integer), float (floating-point, also known as Double), string (string).
Two types of Conformance: Array (array), object
Two special types: resource (Resource), NULL (no type)
The type of the variable is usually not set by the programmer, but rather is determined by the context in which PHP is used according to the variable.
Note: If you want to see the value and type of an expression, use the Var_dump () function. Use the GetType () function if you just want a readable type of expression for debugging purposes. To view a type, do not use GetType () and use the Is_type function.
<?php
Header("Content-type:text/html;charset=utf-8");
$a _bool=TRUE;//a Boolean
$a _str= "Foo";//A String
$a _str2= ' Foo ';//A String
$an _int= 12;//An integer
EchoGetType($a _bool);//Prints Out:boolean
EchoGetType($a _str);//Prints out:string
if(Is_int($an _int)){
$an _int+ = 4;
Echo$an _int;//Print Out:16
}
if(is_string($a _bool)){
Echo"String:$a _bool";
}
?>
If you want to force a variable into a type, you can use a cast or settype () function on it.
Introduction to PHP Data types