PHP gettype() Function

PHP Variable Handling Reference : Return the type of different variables

Definition and Usage

The gettype() function returns the type of a variable.

Syntax

gettype(variable);

Parameter Values

Parameter Description
variable Required. Specifies the variable to check

Technical Details

Return Value: The type as a string. Can be one of the following values: "boolean", "integer", "double", "string", "array", "object", "resource", "NULL", "unknown type"
Return Type: String
PHP Version: 4.0+
PHP Changelog: PHP 7.2: Closed resources are now returned as "resource (closed)". Earlier, the returned value was "unknown type".

❮ PHP Variable Handling Reference