Overflow¶
Overflow happens when a value goes beyond a limit: out of its range of existence, the behavior of the value is now unknown.
Overflow happens with integers, limited to PHP_INT_MAX and PHP_INT_MIN, floats PHP_FLOAT_MAX and PHP_FLOAT_MIN.
Other situations, such as accessing an array element or a string character beyond its last element, defaults to returning null.
There is a native class called OverflowException, which is emitted when a number gets too large, and may be caught.
<?php
$a = PHP_INT_MAX;
$b = (int) ($a + 1);
echo $a.PHP_EOL;
echo $b;
?>
Related : Null, RangeException, Underflow, OverflowException, Standard PHP Library (SPL), Edge Case