php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45324 SWITCH function major bug
Submitted: 2008-06-20 16:47 UTC Modified: 2008-06-20 21:11 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: philip dot almeida at ippimail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.2.6 OS: Windows && Unix
Private report: No CVE-ID: None
 [2008-06-20 16:47 UTC] philip dot almeida at ippimail dot com
Description:
------------
Bug in function SWITCH when processing a 0 digit.
Looks like Bug #37656: Incorrect switch example must be reopened.

Reproduce code:
---------------
$test = 0;
switch($test){
    case 'ONE':
        $result = 'one';
        break;
    case 0:
        $result = 'two';
        break;
    default:
        $result = 'default';
}

print $result;

Expected result:
----------------
two

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-20 21:11 UTC] colder@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

switch doesn't compare strictly, and 0 == 'ONE' is true.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 14:04:04 2025 UTC