PHP is_integer() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Variables

Definition

In PHP, is_integer() is an alias of is_int(). It checks whether a variable is an integer and returns true or false.

Both functions are identical, so you can use either name. The preferred form in modern PHP is is_int(), because it is shorter and matches the int type name. is_integer() remains for compatibility with older code.

Syntax

Call is_integer() with the values you need. Start with this line.

PHP
$result = is_integer($value);
CallWhat it does
is_integer(10)Returns true, because 10 is an integer.
is_integer("10")Returns false, because "10" is a string.
is_integer(10.0)Returns false, because 10.0 is a float.

is_integer() is an alias, so it behaves exactly like is_int(). The preferred form is is_int(). Both work in PHP 8, and neither is deprecated.

Library declarations
PHP
// is_integer() is an alias of is_int()
is_integer(mixed $value): bool

Parameters

ParameterDescription
valueRequired. The variable or value to test.

Return Value

Return ValueDescription
booltrue if the value is an integer, otherwise false.

PHP Examples

Example 1 — Integers and Non-Integers

Test a positive integer, a numeric string, a float and a negative integer.

PHP
<?php
var_dump(is_integer(10));
var_dump(is_integer("10"));
var_dump(is_integer(10.0));
var_dump(is_integer(-5));

How It Works

  1. 10 is a whole number, so it is an integer.
  2. "10" has quotes, so it is a string and the result is false.
  3. 10. 0 has a decimal point, so it is a float.
  4. -5 is a negative whole number, so it is an integer.

Example 2 — Alias Proof and Other Types

Confirm that is_integer() equals is_int(), and check types that are easy to confuse with integers.

PHP
<?php
var_dump(is_integer(5) === is_int(5));
var_dump(is_integer(true));
var_dump(is_integer(null));
var_dump(is_integer(""));

How It Works

  1. Both functions give the same answer for 5, so the strict comparison is true. That proves is_integer() is an alias.
  2. true is a boolean. PHP can convert it to 1, but it is not an integer.
  3. null means no value, so it is not an integer.
  4. An empty string is a string, so the result is false.

Example 3 — Filtering Integers from a Mixed List

Pass is_integer as a callback name to keep only the true integers in an array.

PHP
<?php
$mixed = [1, "2", 3.0, 4, "x"];

$ints = array_filter($mixed, 'is_integer');

echo implode(", ", $ints), PHP_EOL;
echo count($ints), PHP_EOL;

How It Works

  1. The array holds an integer, two strings and a float, so the types are mixed.
  2. array_filter() calls is_integer() on every item and keeps the items that return true.
  3. Only 1 and 4 are real integers. "2" is a string and 3.0 is a float.
  4. implode() joins the remaining values, and count() shows that two items were kept. In new code, use 'is_int' as the callback.

Frequently Asked Questions

is_integer() is an alias of is_int(). It returns true if a variable is an integer and false for every other type.
None. They are the same function. is_int() is the preferred name, and is_integer() is kept for compatibility.
No. It still works in PHP 8. But is_int() is shorter and is the name used in the PHP manual and most modern code.
No. "10" is a string. is_integer() checks the type, so only real integers give true. Use filter_var() with FILTER_VALIDATE_INT to validate text.
Use is_float($x) && floor($x) == $x. You can also check that fmod($x, 1) equals 0. is_integer() on its own returns false for every float.

Next: is_iterable()

is_iterable() checks whether a value can be looped over with foreach. It returns true for .

is_iterable() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful