Where To Put The Cast?

../_images/put_the_cast_where.png

Start from a string, and turn it into a negative number. It is actually as simple as adding the - sign in front of the string.

But that might generate a warning, upon non-numeric string. So, the safe way is to cast the string to (int), and then, take the opposite.

Now, this is safe, but too long. In fact, this can be shortened by adding the (int) between the string and the sign, to cast first, then negate.

And, of course, one may also add the noscream operator @.

See Also

PHP Error Messages

PHP Features