gettype
gettype
gettype
It is used to get the type of a variable
Syntax:
string gettype ( mixed var)
It returns the data type of the given variable var.
Some of the possibles values for the returned string are:
“boolean”
“integer”
“double”
“string”
“array”
“object”
“resource”
“NULL”
“unknown type”
Example:
$input = array(1,2,3);
echo $type1 = gettype(”hello”);
echo $type2 = gettype(1);
echo $type3 = gettype(TRUE);
echo $type4 = gettype(2.3);
echo $type5 = gettype($input);
The result in $type1 is string.
The result in $type2 is integer.
The result in $type3 is boolean.
The result in $type4 is double.
The result in $type5 is array.
