Scalar Types and Their Limits

The scalar types are bool, int, float and string. An int is signed 64-bit, written in decimal, 0x1A, 0b1010 or 0o17 (the 0o prefix is PHP 8.1; a leading zero still means octal), with _ allowed between digits since 7.4. A float is an IEEE 754 double with about 15 significant digits. A string is bytes with no encoding attached.

Where the scalar types run out (scalars.php)PHP
<?php
var_dump(0o17, PHP_INT_MAX + 1, 0.1 + 0.2, 0.1 + 0.2 == 0.3);
var_dump(7 / 2, intdiv(7, 2), strlen('café'), (int) 1e20);
Output
int(15)
float(9.223372036854776E+18)
float(0.30000000000000004)
bool(false)
PHP Warning:  The float 1.0E+20 is not representable as an int, cast occurred in
  /tmp/ch04-02/scalars.php on line 3
float(3.5)
int(3)
int(5)
int(7766279631452241920)

Integer overflow silently becomes a float. Never compare floats with == or keep money in them; count cents in an int or use BcMath\Number (PHP 8.4). Dividing by zero throws DivisionByZeroError, and strlen() counts bytes, so é counts twice (mb_strlen() counts characters). PHP 8.5 is the first version to warn when a float too large for an int casts to garbage; the warning prints first because every argument is evaluated before var_dump() runs.