Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

is_int()

Check for an actual integer when validating an index.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

is_int(mixed $value): bool

Check for an actual integer when validating an index. A whole-valued float and a numeric string still have different types. The predicate accepts zero and negative integers, so checking a nonnegative range requires another condition.

Signature

is_int(mixed $value): bool

Example output

[true,true,false,false,false]

Examples

<?php
echo json_encode(array_map("is_int", [0, -1, 2.0, "2", false]));

Result

[true,true,false,false,false]

Sources