NewbieNotes is a little series of tips for people who are new to PHP to give them a few handy tips that the more experienced of us use often
I sometimes feel sorry for ASP developers, they miss one lovely thing we've had for a good while now. We can tell when false actually is false (they can't)
I distinctly remember reading an article in a 'technical' computer magazine where the author had no idea at all why we needed to know the dirrefence - I suppose his brain rotted through that conbstant exposure to VB!
The difference between something being false or true is, classically, whether it's zero or not. That's how the CPU handles it, after all.
The most well known example of the difference in PHP is the strpos() function. A searched for string can start right at the beginning. As PHP's index to a string starts at zerolooking for 'the' in 'the quick brown fox' would return a zero.
If it's important to find out whether 'the' is in the string an if statement won't cut it! Well, unless you use PHP, of course...
PHP knows the difference between the number zero and the boolean value false. Many functions return either something or false. You can tell the difference in PHP (poor ASP suckers!)
if($var) { do something } will fail if $var is ither zero or false
if($var !== false) { do something } will let zero thru but block flase
Similarly
if($var === false) { do something } will block everything except a false value (not zero)
Whenever you see that a function returns false for some condition use it to your advantage - take pity on the ASP crowd...