ID: 31380 Updated by: [EMAIL PROTECTED] Reported By: alex at arjomand dot net -Status: Open +Status: Bogus Bug Type: *General Issues Operating System: Windows XP Pro PHP Version: 4.3.10 New Comment:
This is by design and won't change. Previous Comments: ------------------------------------------------------------------------ [2005-01-02 23:30:24] alex at arjomand dot net Sorry, that last line in the Reproduce code should read: echo ("alex" == false) === false; # returns TRUE ------------------------------------------------------------------------ [2005-01-02 23:28:15] alex at arjomand dot net Description: ------------ There is a problem with PHP's logic and string conventions. Currently, the comparison 0 == "alex" (or any arbitrary string) returns true. The comparison 0 == false also returns true, but the comparison "alex" == false returns false. This gives us the following logical fallacy: A == B, B == C, but A != C. The first comparison (0 == 'alex') is due to a PHP convention explained here: http://ca.php.net/manual/en/language.types.string.php#language.types.string.conversion The third comparison ("alex" == false) is due to an implicit PHP convention - that any non-empty string is true. These two conventions are inconsistent, and lead to the above errors. Under this system, PHP no longer has referential integrity. Reproduce code: --------------- <? echo (0 == false) === true; # returns true echo "<br>"; echo (0 == "alex") === true; # returns true echo "<br>"; echo ("alex" == false) === false; # returns false ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31380&edit=1