PHP Integer Data Type With Examples

Integer Data Type:

Rules for integers:

  • The range of integers must lie between -2^31 to 2^31.
  • Integers are whole numbers, without a decimal point (..., -2, -1, 0, 1, 2, ...).
  • An integer must have at least one digit
  • An integer must not have a decimal point
  • An integer can be either positive or negative
  • Integers can be specified in three formats: decimal (10-based), hexadecimal (16-based - prefixed with 0x) or octal (8-based - prefixed with 0)
Notation Preceded with Example
Decimal 128
Hexadecimal 0x 0x80
Octal 0 0200
Binary 0b 0b10000000

Example:



Result:

 int(123)
 int(-123)
 int(26)
 int(83)

Read More: