PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I use empty() more frequently, as this tests for NULL, '', and 0 for numerics (check here http://uk3.php.net/manual/en/function.empty.php for more). I would think that == '' would have a performance advantage, but not sure what the recommended usage is.
Thanks for the replies. I often get stuck trying to keep track of integers and strings and for example I was testing to see if a field in the db was 0 (zero) and wasn’t sure if I should go with:-
Wow I never knew null == an empty array. How interesting
Oh hey, I just noticed something. You know phpBB use empty() to check if stuff is...well, empty. Since empty() thinks '0' == '', if you just try and post 0, it'll treat your post as empty. How stupid...go ahead, try it