Doc #64453 [Opn->Csd]: array_key_exists function
Edit report at https://bugs.php.net/bug.php?id=64453&edit=1
ID: 64453
Updated by: ab@php.net
Reported by: billsion at gmail dot com
Summary: array_key_exists function
-Status: Open
+Status: Closed
Type: Documentation Problem
Package: Online Doc Editor problem
Operating System: Windows
PHP Version: 5.3.23
-Assigned To:
+Assigned To: ab
Block user comment: N
Private report: N
New Comment:
IMHO you get it wrong, if I read that doc page:
array_key_exists() returns TRUE if the given key is set in the array. key can be any value possible
for an array index.
and also:
mixed indicates that a parameter may accept multiple (but not necessarily all) types.
Possible for key are int|string which is also what mixed means.
Previous Comments:
------------------------------------------------------------------------
[2013-03-19 06:52:19] billsion at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.array-key-exists#refsect1-function.array-key-exists-description
---
array_key_exists function accept two parameters, the first one is "Mixed" which is tell in
the documentation, but it gives a warning : 'it must be string or integer'. there should
not display any warning even I set the error_reporting is "E_ALL | E_STRICT".
Test script:
---------------
<?php
$key = array('trade_mode', 'trade_state');
$params['trade_mode'] = 1;
$params['trade_state'] = 1;
$params['a'] = 1;
$params['b'] = 1;
if(array_key_exists($key, $params)){
echo 1;
}else{
echo 2;
}
exit;
Expected result:
----------------
1
Actual result:
--------------
Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a
string or an integer in D:\www\index.php on line 9
2
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64453&edit=1
Thread (2 messages)