GETTYPE(3) 1 GETTYPE(3)
gettype - Get the type of a variable
SYNOPSIS
string gettype (mixed $var)
DESCRIPTION
Returns the type of the PHP variable $var. For type checking, use is_* functions.
PARAMETERS
o $var
- The variable being type checked.
RETURN VALUES
Possible values for the returned string are:
o "
boolean"
o "
integer"
o "
double" (for historical reasons "double" is returned in case of a float, and not simply "float")
o "
string"
o "
array"
o "
object"
o "
resource"
o "
NULL"
o "unknown type"
EXAMPLES
Example #1
gettype(3) example
<?php
$data = array(1, 1., NULL, new stdClass, 'foo');
foreach ($data as $value) {
echo gettype($value), "
";
}
?>
The above example will output something similar to:
integer
double
NULL
object
string
SEE ALSO
settype(3), get_class(3), is_array(3), is_bool(3), is_callable(3), is_float(3), is_int(3), is_null(3), is_numeric(3), is_object(3),
is_resource(3), is_scalar(3), is_string(3), function_exists(3), method_exists(3).
PHP Documentation Group GETTYPE(3)