Cast But Not A Cast

../_images/cast_but_not_cast.png

One frequent way to convert a string to an integer is to + 0 it. And, similarly, a frequent way to convert an integer into a string is to . '', aka concatenate the empty string.

The operators often proceed with a silent cast before running the actual operation. Hence, when using the neutral element of that operator, only the cast remains.

Note also that the silent cast is actually not silent when there is an issue with the conversion, while an actual cast silences these warnings: it is always better to use the cast.

Here are the other cases.

See Also

PHP Error Messages

PHP Features