|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15201 ('foo'==0) => equal ?
Submitted: 2002-01-24 06:15 UTC Modified: 2002-01-24 06:20 UTC
From: alberty at neptunelabs dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.0CVS-2002-01-24 OS: i688-gnu-linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: alberty at neptunelabs dot de
New email:
PHP Version: OS:


 [2002-01-24 06:15 UTC] alberty at neptunelabs dot de
A simple condition with a strange result:

if ($a==$b) echo 'equal';
else echo 'not equal';

result: $a and $b is equal,
but if $b unequal zero
the condition results 'not equal'

This is not really rationally.

Is the problem the automatic type casting?




Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-24 06:20 UTC]
It's indeed due to automatic conversion. The vars get converted to ints, and the integer value of 'foo' = 0
Use if ($a === $b) to check for both value and type.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC