Utilizor
Contact Us

PHP Numbers

Integers, Floats, and Number strings.

PHP Numbers

One thing to notice about PHP is that it provides automatic data type conversion.

So, if you assign an integer value to a variable, the type of that variable will automatically be an integer. Then, if you assign a string to the same variable, the type will change to a string.

PHP Integers

2, 256, -256, 10358, -179567 are all integers.

  • An integer must result in a whole number
  • An integer must be at least one digit (0-9)
  • An integer cannot contain decimal point or commas

PHP Floats

A float (floating point number) is a number with a decimal point or a number in exponential form.

2.0, 256.4, 10.358, 7.64E+5, 5.56E-5 are all floats.

PHP Infinity

A numeric value that is larger than PHP_FLOAT_MAX is considered infinite.