gettype Function in PHP

What is gettype() in PHP?

Explanation

PHP gettype function is used to get the type of the given variable.

Syntax:


gettype(var_name)

Possible return values are:


 Integer
 Boolean
 String
 Double
 NULL
 Array
 Object

Example :


<?php
$val1 = 123;
$val2 = 3.1;
$val3=true;
$val4="Hscripts";
echo gettype($val1)."<br />";
echo gettype($val2)."<br />";
echo gettype($val3)."<br />";
echo gettype($val4)."<br />";
?>

Result :

integer
double
boolean
string

PHP Topics


Ask Questions

Ask Question