Bug #80490 [Com]: Switch choose a wrong block, if int(0) is a value
| From: | rjrjdjdu at dfjdrj dot com | Date: | Mon, 07 Dec 2020 12:52:59 +0000 |
| Subject: | Bug #80490 [Com]: 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-230895@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
Comment by: rjrjdjdu at dfjdrj dot com
Reported by: miso at fykos dot cz
Summary: Switch choose a wrong block, if int(0) is a value
Status: Open
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:
learn about type juggeling - "a" casted to int is 0
Previous Comments:
------------------------------------------------------------------------
[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