1--TEST-- 2Indexing - various special cases. 3--FILE-- 4<?php 5echo "*** Indexing - Testing value assignment with key ***\n"; 6$array=array(1); 7$testvalues=array(null, 0, 1, true, false,'',' ',0.1,array()); 8 9foreach ($testvalues as $testvalue) { 10 try { 11 $testvalue['foo']=$array; 12 } catch (Error $e) { 13 echo $e->getMessage(), "\n"; 14 } 15 var_dump($testvalue); 16} 17echo "\n*** Indexing - Testing reference assignment with key ***\n"; 18 19$testvalues=array(null, 0, 1, true, false,0.1,array()); 20 21foreach ($testvalues as $testvalue) { 22 try { 23 $testvalue['foo']=&$array; 24 } catch (Error $e) { 25 echo $e->getMessage(), "\n"; 26 } 27 var_dump($testvalue); 28} 29echo "*** Indexing - Testing value assignment no key ***\n"; 30$array=array(1); 31$testvalues=array(null, 0, 1, true, false,0.1,array()); 32 33foreach ($testvalues as $testvalue) { 34 try { 35 $testvalue[]=$array; 36 } catch (Error $e) { 37 echo $e->getMessage(), "\n"; 38 } 39 var_dump ($testvalue); 40} 41echo "\n*** Indexing - Testing reference assignment no key ***\n"; 42 43$testvalues=array(null, 0, 1, true, false,0.1,array()); 44 45foreach ($testvalues as $testvalue) { 46 try { 47 $testvalue[]=&$array; 48 } catch (Error $e) { 49 echo $e->getMessage(), "\n"; 50 } 51 var_dump ($testvalue); 52} 53 54?> 55--EXPECTF-- 56*** Indexing - Testing value assignment with key *** 57array(1) { 58 ["foo"]=> 59 array(1) { 60 [0]=> 61 int(1) 62 } 63} 64Cannot use a scalar value as an array 65int(0) 66Cannot use a scalar value as an array 67int(1) 68Cannot use a scalar value as an array 69bool(true) 70 71Deprecated: Automatic conversion of false to array is deprecated in %s 72array(1) { 73 ["foo"]=> 74 array(1) { 75 [0]=> 76 int(1) 77 } 78} 79Cannot access offset of type string on string 80string(0) "" 81Cannot access offset of type string on string 82string(1) " " 83Cannot use a scalar value as an array 84float(0.1) 85array(1) { 86 ["foo"]=> 87 array(1) { 88 [0]=> 89 int(1) 90 } 91} 92 93*** Indexing - Testing reference assignment with key *** 94array(1) { 95 ["foo"]=> 96 &array(1) { 97 [0]=> 98 int(1) 99 } 100} 101Cannot use a scalar value as an array 102int(0) 103Cannot use a scalar value as an array 104int(1) 105Cannot use a scalar value as an array 106bool(true) 107 108Deprecated: Automatic conversion of false to array is deprecated in %s 109array(1) { 110 ["foo"]=> 111 &array(1) { 112 [0]=> 113 int(1) 114 } 115} 116Cannot use a scalar value as an array 117float(0.1) 118array(1) { 119 ["foo"]=> 120 &array(1) { 121 [0]=> 122 int(1) 123 } 124} 125*** Indexing - Testing value assignment no key *** 126array(1) { 127 [0]=> 128 array(1) { 129 [0]=> 130 int(1) 131 } 132} 133Cannot use a scalar value as an array 134int(0) 135Cannot use a scalar value as an array 136int(1) 137Cannot use a scalar value as an array 138bool(true) 139 140Deprecated: Automatic conversion of false to array is deprecated in %s 141array(1) { 142 [0]=> 143 array(1) { 144 [0]=> 145 int(1) 146 } 147} 148Cannot use a scalar value as an array 149float(0.1) 150array(1) { 151 [0]=> 152 array(1) { 153 [0]=> 154 int(1) 155 } 156} 157 158*** Indexing - Testing reference assignment no key *** 159array(1) { 160 [0]=> 161 &array(1) { 162 [0]=> 163 int(1) 164 } 165} 166Cannot use a scalar value as an array 167int(0) 168Cannot use a scalar value as an array 169int(1) 170Cannot use a scalar value as an array 171bool(true) 172 173Deprecated: Automatic conversion of false to array is deprecated in %s 174array(1) { 175 [0]=> 176 &array(1) { 177 [0]=> 178 int(1) 179 } 180} 181Cannot use a scalar value as an array 182float(0.1) 183array(1) { 184 [0]=> 185 &array(1) { 186 [0]=> 187 int(1) 188 } 189} 190