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