Posted on 13/8/07 by Felix Geisendörfer
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.
echo 0 + 1; // 1
echo false + 1; // 1
echo 0 > -1; // true
// But what is that ...?
echo false > -1; // false
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:
More posts are to come,
You can skip to the end and add a comment.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.