• PHP Video Tutorials

PHP - is_integer() Function



Definition and Usage

The function is_integer() checks whether the type of a variable is integer. This function is an alias of is_int().

Syntax

bool is_integer ( mixed $value )

Parameters

Sr.No Parameter & Description
1

value

The variable whose type is being evaluated.

Return Values

This function returns true if value is an int, false otherwise.

Dependencies

PHP 4 and above

Example

Following example demonstrates return values with different types of variables −

<?php
   $a = 33;
   echo "a is "; var_dump(is_integer($a)); echo "<br>";

   $b = "33";
   echo "b is "; var_dump(is_integer($b)); echo "<br>";

   $c = 33.5;
   echo "c is "; var_dump(is_integer($c)); echo "<br>";

   $d = "33.5";
   echo "d is "; var_dump(is_integer($d)); echo "<br>";

   $e = true;
   echo "e is "; var_dump(is_integer($e)); echo "<br>";

   $f = false;
   echo "f is "; var_dump(is_integer($f)); echo "<br>";

   $g = null;
   echo "g is "; var_dump(is_integer($g)); echo "<br>";
?>

Output

This will produce following result −

a is bool(true)
b is bool(false)
c is bool(false)
d is bool(false)
e is bool(false)
f is bool(false)
g is bool(false)
php_variable_handling_functions.htm
Advertisements