php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49179 zero problem in if and switch
Submitted: 2009-08-06 16:05 UTC Modified: 2009-08-06 20:07 UTC
From: steve at ezd dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 5.2.10 OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: steve at ezd dot com
New email:
PHP Version: OS:

 

 [2009-08-06 16:05 UTC] steve at ezd dot com
Description:
------------
please run source code, it's self explained
it seems that when use 0 to compare with string, it returns true all the time,
problem in if is when using ==, === has no problem
in switch case, it matches the first non number case

Reproduce code:
---------------
		if (0=="a")	echo "this is ture.";
		$check=0;
		switch ($check)
		{
			case 'a':
			echo "this is a ";
			break;
			default :
			echo "no match";
		}

Expected result:
----------------
no match

Actual result:
--------------
this is ture.this is a 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-06 20:07 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

PLEASE search the bug database before you submit same issue as a bug 
again. This is not a bug. It's said in the manual too, try reading that 
also.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 16:01:35 2024 UTC