php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32172 Switch 0 Bug (first case)
Submitted: 2005-03-03 14:37 UTC Modified: 2005-03-03 15:52 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: daniel dot elsner at tvi-services dot de Assigned:
Status: Not a bug Package: Variables related
PHP Version: 5.0.3 OS: Linux (Fedore Core3)
Private report: No CVE-ID: None
 [2005-03-03 14:37 UTC] daniel dot elsner at tvi-services dot de
Description:
------------
a switch on a String variable go in the first case if the Variable 0. if the variable "0" its right and he goes in default!

Reproduce code:
---------------
$fish = 0;
switch($fish) {
		case "one":
			echo "one";
			break;
		case "two":
			echo "two";
			break;
		default:
			echo "default";
			break;
}

Expected result:
----------------
default

Actual result:
--------------
one

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-03 15:05 UTC] KRomas at goldentele dot com
bogus, not a bag

var_dump(0=='one');
var_dump(0==='one');
 [2005-03-03 15:52 UTC] johannes@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

If an integer is compared with a string the string is 
converted to an integer. 
http://de.php.net/manual/en/types.comparisons.php 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 01 10:01:30 2024 UTC