1--TEST-- 2Test array_fill_keys() function : variation of parameter 3--FILE-- 4<?php 5/* Prototype : proto array array_fill_keys(array keys, mixed val) 6 * Description: Create an array using the elements of the first parameter as keys each initialized to val 7 * Source code: ext/standard/array.c 8 * Alias to functions: 9 */ 10 11/* Testing with reference types for the arguments */ 12 13echo "*** Testing array_fill_keys() : parameter variations ***\n"; 14 15$nullVal = null; 16$simpleStr = "simple"; 17$refString = &$simpleStr; 18$fp = fopen(__FILE__, "r"); 19$emptyArr = array(); 20$bool = false; 21$float = 2.4; 22 23class classA { 24 public function __toString() { return "Class A object"; } 25} 26$obj = new classA(); 27 28 29echo "\n-- Testing array_fill_keys() function with reference value --\n"; 30$keyedArray = array("one", "two"); 31var_dump(array_fill_keys($keyedArray, $refString)); 32 33echo "\n-- Testing array_fill_keys() function with reference keys --\n"; 34$refKeys = array("one", &$simpleStr); 35$res = array_fill_keys($refKeys, $simpleStr); 36var_dump($res); 37$simpleStr = "bob"; 38var_dump($res); 39 40 41echo "\n-- Testing array_fill_keys() function with reference array input --\n"; 42$newArray = array("one", "two"); 43$refArray = &$newArray; 44var_dump(array_fill_keys($refArray, $simpleStr)); 45 46fclose($fp); 47echo "Done"; 48?> 49--EXPECTF-- 50*** Testing array_fill_keys() : parameter variations *** 51 52-- Testing array_fill_keys() function with reference value -- 53array(2) { 54 ["one"]=> 55 string(6) "simple" 56 ["two"]=> 57 string(6) "simple" 58} 59 60-- Testing array_fill_keys() function with reference keys -- 61array(2) { 62 ["one"]=> 63 string(6) "simple" 64 ["simple"]=> 65 string(6) "simple" 66} 67array(2) { 68 ["one"]=> 69 string(6) "simple" 70 ["simple"]=> 71 string(6) "simple" 72} 73 74-- Testing array_fill_keys() function with reference array input -- 75array(2) { 76 ["one"]=> 77 string(3) "bob" 78 ["two"]=> 79 string(3) "bob" 80} 81Done 82