Get the type of a variable with gettype() in PHP

Description

The following code shows how to get the type of a variable with gettype().

Example


/*w w w  .  j a  v  a 2  s  . c o  m*/
<?php

$data = array(1, 1., NULL, new stdClass, 'foo');

foreach ($data as $value) {
    echo gettype($value), "\n";
}

?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition