False == 0, or not?
Posted by Felix Geisendörfer, on Aug 13, 2007 - in PHP & CakePHP » Other
So far I've always thought false would evaluate to 0 when used in a computational context. Turns out that this isn't always the case.
php
-
// The world as we know it:
-
-
// But what is that ...?
Now if anybody does have an explanation for this, I'd be glad to hear it. I randomly stumbled upon this when arguing with Mariano today if setting Model::recursive to 'false' has the same effect as setting it to '-1'. Turns out that cake uses a statement like this: if ($recursive > -1) in the core which in turn makes -1 and false do exactly the same thing.
Btw., if you need to work around this behavior you can use something like this:
php
More posts are to come,
-- Felix