php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14240 IF behaving weird
Submitted: 2001-11-26 15:32 UTC Modified: 2001-11-26 15:35 UTC
From: kvzp at novae dot dhs dot org Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.6 OS: Linux RedHat 7.1
Private report: No CVE-ID: None
 [2001-11-26 15:32 UTC] kvzp at novae dot dhs dot org
$foo = "foo";

if ( "foo" == 0 )
{ echo "1"; }

if ( $foo == 0 )
{ echo "2"; }


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-26 15:35 UTC] derick@php.net
This prints "12" for me, which is what I would expect. A string evaluates to 0 upon conversion to an integer. You should use === to check for both type and value.

Derick
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Sep 08 05:01:27 2024 UTC