Req #72866 [NEW]: in_array confusing strings and integers
From: imbibinebe at gmail dot com
Operating system: debian
PHP version: 5.6Git-2016-08-17 (Git)
Package: *General Issues
Bug Type: Feature/Change Request
Bug description:in_array confusing strings and integers
Description:
------------
using PHP Version 5.6.14-0+deb8u1 on a debian operating system, here is
what I get with the following testing script.
I think that 'Expected result' should be obtained without using the
third parameter of in_array ([, bool $strict = FALSE ]) otherwise it is
very confusing.
Test script:
---------------
echo 'test1:'.(in_array('string',[0,1])?'true':'false');
echo 'test2:'.(in_array('string',[1])?'true':'false');
echo 'test3:'.(in_array('string',[0])?'true':'false');
Expected result:
----------------
test1:false
test2:false
test3:false
Actual result:
--------------
test1:true
test2:false
test3:true
--
Edit bug report at https://bugs.php.net/bug.php?id=72866&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72866&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72866&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72866&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72866&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72866&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72866&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72866&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72866&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72866&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72866&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72866&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72866&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72866&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72866&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72866&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72866&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72866&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72866&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72866&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72866&r=mysqlcfg
Thread (9 messages)
- imbibinebe at gmail dot com