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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
35 + 11 = ?
Subscribe to this entry?

 
 [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: Sat May 18 14:01:35 2024 UTC