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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
var_dump(null == 0); // evaluates to true | |
var_dump(null < -1); // this also evaluates to true | |
// so, how can some predefined value be equal to 0 as well as be less than -1? | |
?> |
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?!
No comments:
Post a Comment