Doc #54574 [Opn->Csd]: is_array doesn't have any warning about unexpected type casting
| From: | dtajchreber@php.net | Date: | Wed, 20 Apr 2011 14:03:07 +0000 |
| Subject: | Doc #54574 [Opn->Csd]: is_array doesn't have any warning about unexpected type casting | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-6269@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54574&edit=1
ID: 54574
Updated by: dtajchreber@php.net
Reported by: ss23 at ss23 dot geek dot nz
Summary: is_array doesn't have any warning about unexpected
type casting
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
PHP Version: Irrelevant
-Assigned To:
+Assigned To: dtajchreber
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2011-04-20 16:02:54] dtajchreber@php.net
Added a blurb that in_array uses loose comparison unless $strict is set
and the
default value for the strict parameter is false.
------------------------------------------------------------------------
[2011-04-20 16:00:07] dtajchreber@php.net
Automatic comment from SVN on behalf of dtajchreber
Revision: http://svn.php.net/viewvc/?view=revision&revision=310394
Log: Fixing mistake made with last commit (#54574)
------------------------------------------------------------------------
[2011-04-20 15:58:30] dtajchreber@php.net
Automatic comment from SVN on behalf of dtajchreber
Revision: http://svn.php.net/viewvc/?view=revision&revision=310392
Log: Fixed #54574 - clarified that in_array uses loose comparison by
default
------------------------------------------------------------------------
[2011-04-20 06:21:33] ss23 at ss23 dot geek dot nz
Description:
------------
Consider:
$safeColors =
array(1,2,3,4,5,6,7,8,9,0,'a','b','c','d','e','f');
var_dump(in_array('T', $safeColors));
People not paying attention would assume "false", however, because T is
compared
with integers, it seems to be cast to 0, therefore, outputting true.
A "solution" would be a warning on the in_array page, as this isn't a
problem with
the function, just something that confuses users who aren't expecting
it.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54574&edit=1