(PHP 4, PHP 5, PHP 7)
Get the type of a variable
string gettype ( mixed $var )
Returns the type of the PHP variable var
. For type checking, use is_* functions.
Parameters:
var
The variable being type checked.
Returns:
Possible values for the returned string are:
- "boolean"
- "integer"
- "double" (for historical reasons "double" is returned in case of a float, and not simply "float")
- "string"
- "array"
- "object"
- "resource"
- "NULL"
- "unknown type"
Examples:
gettype() example
<?php $data = array(1, 1., NULL, new stdClass, 'foo'); foreach ($data as $value) { echo gettype($value), "\n"; } ?>
The above example will output something similar to:
integer double NULL object string
See also:
is_int() -
Please login to continue.