Bug #79216 [Nab]: in_array bug
| From: | cmb@php.net | Date: | Mon, 03 Feb 2020 16:56:31 +0000 |
| Subject: | Bug #79216 [Nab]: in_array bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225336@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79216&edit=1
ID: 79216
Updated by: cmb@php.net
Reported by: uugv_tl at 163 dot com
Summary: in_array bug
Status: Not a bug
Type: Bug
Package: *General Issues
Operating System: macos 10.15.3
PHP Version: 7.2.27
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Like stated in the comment above: you're hitting type-juggling.
Previous Comments:
------------------------------------------------------------------------
[2020-02-03 16:55:22] requinix@php.net
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
------------------------------------------------------------------------
[2020-02-03 16:20:49] bugreports at gmail dot com
https://www.php.net/manual/en/language.types.type-juggling.php
https://www.php.net/manual/en/function.in-array.php
strict
If the third parameter strict is set to TRUE then the in_array() function will also check the
types of the needle in the haystack.
------------------------------------------------------------------------
[2020-02-03 15:54:53] uugv_tl at 163 dot com
Description:
------------
$arr = array('b', 0);
if(in_array('abc',$arr))
{
echo 'ok';
}
else
{
echo 'bad'
}
when above statement echo 'ok',shoud be echo 'bad' right?
Test script:
---------------
$arr = array('b', 0);
if(in_array('abc',$arr))
{
echo 'ok';
}
else
{
echo 'bad'
}
shoud be echo 'bad',but echo 'ok'
Expected result:
----------------
'bad'
Actual result:
--------------
'ok'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79216&edit=1