Bug #80490 [Opn->Nab]: Switch choose a wrong block, if int(0) is a value
| From: | peehaa@php.net | Date: | Mon, 07 Dec 2020 12:56:28 +0000 |
| Subject: | Bug #80490 [Opn->Nab]: Switch choose a wrong block, if int(0) is a value | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-230896@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=80490&edit=1
ID: 80490
Updated by: peehaa@php.net
Reported by: miso at fykos dot cz
Summary: Switch choose a wrong block, if int(0) is a value
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: ubuntu 18.04
PHP Version: 7.4.13
Block user comment: N
Private report: N
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
In particular:
https://www.php.net/manual/en/control-structures.switch.php
and https://www.php.net/manual/en/language.types.type-juggling.php
and
Previous Comments:
------------------------------------------------------------------------
[2020-12-07 12:52:59] rjrjdjdu at dfjdrj dot com
learn about type juggeling - "a" casted to int is 0
------------------------------------------------------------------------
[2020-12-07 12:08:35] miso at fykos dot cz
Description:
------------
When argument of switch is a int(0), switch choose a wrong statement.
Test script:
---------------
<?php
$key = 0;
switch ($key) {
case 'a':
echo 'break';
break;
default:
echo 'default';
break;
}
Expected result:
----------------
'default'
Actual result:
--------------
'break'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80490&edit=1