Oversigned Integers

../_images/signed_integer.png

PHP has signed integers. They may be positive or negative, with + or -.

At parsing time, integers and their sign are separate entities. This means that - and 3 are process in two steps, and PHP allows the chaining of the sign operators. This means that + and - may be added as much as we want, in front of integers, as long as they alternate.

Note that is_numeric() is not fooled by the trick, and returns false on such strings, while the cast operator (int) turns the string into 0, as if there was an error.

Finally, there is one integer which is equal to itself when positive or negative: zero.

See Also

PHP Error Messages

PHP Features