1--TEST-- 2Test array_key_exists() function : usage variations - referenced variables 3--INI-- 4allow_call_time_pass_reference=on 5--FILE-- 6<?php 7/* Prototype : bool array_key_exists(mixed $key, array $search) 8 * Description: Checks if the given key or index exists in the array 9 * Source code: ext/standard/array.c 10 * Alias to functions: key_exists 11 */ 12 13/* 14 * Pass referenced variables as arguments to array_key_exists() to test behaviour 15 */ 16 17echo "*** Testing array_key_exists() : usage variations ***\n"; 18 19$array = array('one' => 1, 'two' => 2, 'three' => 3); 20 21echo "\n-- \$search is a reference to \$array --\n"; 22$search = &$array; 23var_dump(array_key_exists('one', $search)); 24 25echo "\n-- \$key is a referenced variable --\n"; 26$key = 'two'; 27var_dump(array_key_exists(&$key, $array)); 28 29echo "\n-- Both arguments are referenced variables --\n"; 30var_dump(array_key_exists(&$key, &$array)); 31 32echo "Done"; 33?> 34 35--EXPECTF-- 36*** Testing array_key_exists() : usage variations *** 37 38-- $search is a reference to $array -- 39bool(true) 40 41-- $key is a referenced variable -- 42bool(true) 43 44-- Both arguments are referenced variables -- 45bool(true) 46Done 47