Bug #79941 [Opn->Nab]: If statement comparison bug
| From: | cmb@php.net | Date: | Fri, 07 Aug 2020 06:20:37 +0000 |
| Subject: | Bug #79941 [Opn->Nab]: If statement comparison bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-228441@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79941&edit=1
ID: 79941
Updated by: cmb@php.net
Reported by: wdh at allcode dot io
Summary: If statement comparison bug
-Status: Open
+Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: CentOS
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
By the way, the PHP version is not irrelevant in this case.
Previous Comments:
------------------------------------------------------------------------
[2020-08-07 05:11:46] wdh at allcode dot io
Not only in the foreach loop, the If statement produce the bug.
------------------------------------------------------------------------
[2020-08-07 05:10:14] wdh at allcode dot io
Not only in the foreach loop, the If statement produce the bug.
Test script:
---------------
$str = 'ex';
if($str == 0) {
echo $str;
}
Expected result:
----------------
(no output)
Actual result:
--------------
ex
------------------------------------------------------------------------
[2020-08-07 05:00:21] wdh at allcode dot io
Description:
------------
In the test code,
if($k == 'ex') statement is malfunctioning.
the statement should be return true only at the 'ex' string, but also return true at the
0.
Test script:
---------------
$arr = [
0 => 'a',
1 => 'b',
'ex' => 'c',
];
foreach($arr as $k => $v) {
if($k == 'ex') {
echo $k;
}
}
Expected result:
----------------
ex
Actual result:
--------------
0ex
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79941&edit=1