Showing posts with label boolean. Show all posts
Showing posts with label boolean. Show all posts

Wednesday, May 6, 2015

PHP Blunder-2

Here is another 'oops!' moment for PHP. Do you remember the rule of transitivity? A related to B, and A related to C, implies that B is related to C. Right? Now apply this very understanding to the code below.
Now, foo equals true, and foo equals zero. So, according to this rule of transitivity, true equals zero?!

Wednesday, April 29, 2015

PHP Blunder - 1

PHP is one of those most popular web programming languages, but it do have some serious mistakes. Here's one of them.

PHP have a predefined value 'null'. And, it can be compared with numeric values. As anybody else would, you would expect null to have a constant value, right? But that's where PHP have a problem. Look at the code below, and execute it on your system if you want to check.

The null == 0 evaluates to true. So does null < -1. How can some predefined value be equal to 0 and lesser than -1 at the same time?!