If you specify a number beyond the bounds of the integer
type, it will be interpreted as a float instead. Also, if
you perform an operation that results in a number beyond the bounds of
the integer type, a float will be returned
Unfortunately, there was a bug in PHP so that this
does not always work correctly when there are negative numbers
involved. For example: when you do -50000 *
$million, the result will be
-429496728. However, when both operands are
positive there is no problem.
This is solved in PHP 4.1.0.
There is no integer division operator in PHP.
1/2 yields the float0.5. You can cast the value to
an integer to always round it downwards, or you can
use the round() function.
To explicitly convert a value to integer, use either
the (int) or the (integer) cast.
However, in most cases you do not need to use the cast, since a value
will be automatically converted if an operator, function or
control structure requires an integer argument.
You can also convert a value to integer with the function
When converting from float to integer, the number will
be rounded towards zero.
If the float is beyond the boundaries of integer
(usually +/- 2.15e+9 = 2^31),
the result is undefined, since the float hasn't
got enough precision to give an exact integer result.
No warning, not even a notice will be issued in this
Never cast an unknown fraction to integer, as this can
sometimes lead to unexpected results.
Behaviour of converting to integer is undefined for other
types. Currently, the behaviour is the same as if the value
was first converted to boolean. However, do
not rely on this behaviour, as it can
change without notice.