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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: phpbug at domaincommunication dot de
New email:
PHP Version: OS:

 

 [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 04:01:32 2024 UTC