php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35349 if return true if values are different $bug = 0 if($bug== "test"){echo "BUG";}
Submitted: 2005-11-23 15:29 UTC Modified: 2005-11-23 16:20 UTC
From: martin at whitewallweb dot com Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.0.5 OS: Windows
Private report: No CVE-ID: None
 [2005-11-23 15:29 UTC] martin at whitewallweb dot com
Description:
------------
if return true if values are different $bug = 0 
if($bug== "test"){echo "BUG";} 

Reproduce code:
---------------
$bug = 0;
if($bug == "BUG")
{
   echo ("There is a bug");

}
else
{
   echo "There is no BUG";
}

Expected result:
----------------
There is no BUG

Actual result:
--------------
There is a bug

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-11-23 15:50 UTC] sniper@php.net
This is propably the most common "bug" reported. 
RTFM.
 [2005-11-23 16:12 UTC] martin at whitewallweb dot com
No Need...

Value 0 is value int 0 and "0" is string "0". This I could understand.

But String "PHP" is not 0 nor NULL.
$var = "PHP";
if($var === 0)
{
    //Code not shown
    echo "know this work";
}

=== more typing than ==

HRTFM.
 [2005-11-23 16:20 UTC] johannes@php.net
User error -> bogus  
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Jul 14 09:01:31 2025 UTC