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
 [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

Pull Requests

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: Sat Dec 21 16:01:28 2024 UTC