In this article, you will learn how to get the type of variable in PHP. The gettype() function in PHP returns the type of a variable.
what is the syntax of the GETTYPE() function in php?
gettype(variable);
Parameter | Description |
---|---|
variable | Required. Specifies the variable to check |
examples of the GETTYPE() function
Example 1. In this example, we get the type of different variables.
<?php
$a = 3;
echo gettype($a) . "<br>";
$b = 3.2;
echo gettype($b) . "<br>";
$c = "Hello";
echo gettype($c) . "<br>";
$d = array();
echo gettype($d) . "<br>";
$e = array("red", "green", "blue");
echo gettype($e) . "<br>";
$f = NULL;
echo gettype($f) . "<br>";
$g = false;
echo gettype($g) . "<br>";
?>