php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9478 Two different types compare problem!
Submitted: 2001-02-27 08:59 UTC Modified: 2001-02-27 09:04 UTC
From: cryp at inet dot lv Assigned:
Status: Not a bug Package: Math related
PHP Version: 4.0.4pl1 OS: Linux
Private report: No CVE-ID: None
 [2001-02-27 08:59 UTC] cryp at inet dot lv
### CODE ###
$Flag = 0;
if ( $Flag == 'N' ) echo "1";
else echo "2";
### END ###
Result: 1

If the $Flag is integer value and 'N' non integer, why this operation gives true as the result?
This is different types 0 and 'N', but if the programm can compare this values, it will be better to give "false"!

Can you explane this ?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-27 09:04 UTC] stas@php.net
Use === for exact comparison. == is 'numeric' comparison.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 08:01:27 2024 UTC