Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

PHP type int

An integer is a signed whole number within platform-dependent limits.

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

Syntax

int $count

An integer is a signed whole number within platform-dependent limits. PHP_INT_MIN and PHP_INT_MAX identify those bounds. Overflow in ordinary arithmetic can produce a float rather than wrapping around. Numeric notation also matters: a leading 0 in a source literal can indicate octal, while an explicit hexadecimal prefix selects base sixteen.

$tooLarge = PHP_INT_MAX + 1;
echo json_encode([010, 0x10, is_int(PHP_INT_MAX), is_float($tooLarge)]);
[8,16,true,true]

Examples

<?php
$tooLarge = PHP_INT_MAX + 1;
echo json_encode([010, 0x10, is_int(PHP_INT_MAX), is_float($tooLarge)]);

Result

[8,16,true,true]

Sources