gettype

string gettype(mixed value) 

Finds the type of a value.

Returns:

String containing the type of the value

Description:

gettype() returns the type of the value argument. The value returned is one of integer, double, string, array, class, object, unknown type, or NULL.

Version:

3+, 4+

Examples:

Find the type for an undefined variable
// $value has not been defined - let's see what type it is 
$type = gettype ($value); 
print "The type of variable <i>\$value</i> is <i>$type</i>."; 
Show the type for each value in a list of values
 <pre> <?php // Make a list of values to test $values = array ( 'array (1,2)' => array (1,2), 'TRUE' => TRUE, 1.23 => 1.23, 1 => 1, '0xFF' => 0xFF, 'NULL' => NULL, "dir('.')" => dir('.'), "opendir ('.')" => opendir ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.