PHP Data type integer


Integer is a number in the set of {..., -2, -1, 0, 1, 2, ...}.

Examples of defining integers:

$var_int = 12345;

Integer values can be specified in decimal, hexadecimal, or octal notation. If octal notation is used, the digits must be preceded by 0(zero) and hexadecimal notation must be preceded by 0x:

$var_int = 0123; // octal number(equal to the decimal 83)
$var_int2 = 0x1A; // Hexadecimal number(equal to 26 in decimal)

Tip: Integer data does not need single or double quotation marks, otherwise it will be treated as a string type to define.


Integer overflow

If a given number is outside the range of an integer, it will be interpreted as a float type. Also returns a float if the result of the operation is out of the integer range.

The range of integers is platform-dependent, usually about two billion(32-bit signed).




Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook