PHP gettype() Function

PHP gettype() Function

The gettype () function in PHP gets the type of the specified variable.

Syntax

gettype ( mixed $var ) 

Parameter

var(required)- This parameter represents the variable being type checked.

Return

This function returns the type of the PHP variable specified by “var” parameter.

The possible returned values are as follows:

  • Boolean
  • Integer
  • Double
  • String
  • Array
  • Object
  • Resource
  • Null

Example 1

 

Output

false is a boolean value
13 is a integer value
51.16 is a double value
Abc3462 is a string value 

Example 2

 

Output

It is an array value
It is an object value
It is a NULL value
It is a resource value 

Example 3

 

Output

string
integer
double
double