php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #64453 array_key_exists function
Submitted: 2013-03-19 06:52 UTC Modified: 2013-03-21 16:25 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: billsion at gmail dot com Assigned: ab (profile)
Status: Closed Package: Online Doc Editor problem
PHP Version: 5.3.23 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: billsion at gmail dot com
New email:
PHP Version: OS:

 

 [2013-03-19 06:52 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-03-21 16:25 UTC] ab@php.net
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.
 [2013-03-21 16:25 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 00:01:34 2024 UTC