Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As an extended note, I think it important that you understand the underlying concepts behind type inference and type coercion, and then to understand how PHP uses those in various circumstances:

- Convert numbers to strings and vice-versa - Compare strings to numbers - Typeless versus typed comparisons (== and ===) - Array keys using '10' (a string) versus 10 (a number)

Once you understand the type inference and type coercion concepts, it should be simple to pick up how it affects your PHP code.

Most importantly, PHP will generally do what's most logical/useful/expected when it comes to these topics, so you generally don't need to think about it, but you should be aware of it in any case.

A good reference can be found in the PHP manual, which gives you tables of comparisons between different data types in different situations: http://www.php.net/manual/en/types.comparisons.php



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: