Return to array_key_exists_variation4.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / array |
1.1 misho 1: --TEST-- 2: Test array_key_exists() function : usage variations - referenced variables 3: --INI-- 4: allow_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: 17: echo "*** Testing array_key_exists() : usage variations ***\n"; 18: 19: $array = array('one' => 1, 'two' => 2, 'three' => 3); 20: 21: echo "\n-- \$search is a reference to \$array --\n"; 22: $search = &$array; 23: var_dump(array_key_exists('one', $search)); 24: 25: echo "\n-- \$key is a referenced variable --\n"; 26: $key = 'two'; 27: var_dump(array_key_exists(&$key, $array)); 28: 29: echo "\n-- Both arguments are referenced variables --\n"; 30: var_dump(array_key_exists(&$key, &$array)); 31: 32: echo "Done"; 33: ?> 34: 35: --EXPECTF-- 36: *** Testing array_key_exists() : usage variations *** 37: 38: -- $search is a reference to $array -- 39: bool(true) 40: 41: -- $key is a referenced variable -- 42: bool(true) 43: 44: -- Both arguments are referenced variables -- 45: bool(true) 46: Done