php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44569 Evaluation of String as Switch/Case Parameter
Submitted: 2008-03-30 11:06 UTC Modified: 2008-03-30 11:36 UTC
From: soenke at brecht dot it Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.5 OS: Unix/Windows
Private report: No CVE-ID: None
 [2008-03-30 11:06 UTC] soenke at brecht dot it
Description:
------------
Case seems to evaluate only parts of the given case name against the in case given comparator.

In the given example it aways runs into the first case, comparing only the first four characters of both strings.

Reproduce code:
---------------
decide("Items");
decide("Item");
decide("some");

function decide ($parameter){

 Switch($parameter){
  case "Items":
   echo "These are all items \n";
   break;
  case "Item":
   echo "A single Item \n";
   break;
  default:
   echo "not listed";
 }//end switch
}//end function

Expected result:
----------------
These are all items
A single item
not listed

Actual result:
--------------
These are all items
These are all items
not listed

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-03-30 11:36 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.

Can't reproduce in both 5.2.5 and 5.3.0.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Dec 14 15:00:01 2025 UTC