php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34503 the switch statement doesn't work correct
Submitted: 2005-09-14 23:35 UTC Modified: 2005-09-14 23:38 UTC
From: phpbug at domaincommunication dot de Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.4.0 OS: winXP SP1, SuSE Linux 9.1
Private report: No CVE-ID: None
 [2005-09-14 23:35 UTC] phpbug at domaincommunication dot de
Description:
------------
the switch statement doesn't compare the number '0' with strings correct.

Reproduce code:
---------------
$act = 0;
$var = '';

switch($act){
   case "search":
      $var = "search"; break;
   case 0:
   case "0":
   case '0':
   case false:
   default:
      $var = "zero";
}

echo $var;

Expected result:
----------------
zero

Actual result:
--------------
search

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-14 23:38 UTC] tony2001@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #34425
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 06:01:33 2024 UTC