xref: /PHP-7.0/Zend/tests/indexing_001.phpt (revision 1f4f33af)
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	$testvalue['foo']=$array;
11	var_dump ($testvalue);
12}
13echo "\n*** Indexing - Testing reference assignment with key ***\n";
14
15$testvalues=array(null, 0, 1, true, false,'',0.1,array());
16
17foreach ($testvalues as $testvalue) {
18	$testvalue['foo']=&$array;
19	var_dump ($testvalue);
20}
21echo "*** Indexing - Testing value assignment no key ***\n";
22$array=array(1);
23$testvalues=array(null, 0, 1, true, false,'',0.1,array());
24
25foreach ($testvalues as $testvalue) {
26	$testvalue[]=$array;
27	var_dump ($testvalue);
28}
29echo "\n*** Indexing - Testing reference assignment no key ***\n";
30
31$testvalues=array(null, 0, 1, true, false,'',0.1,array());
32
33foreach ($testvalues as $testvalue) {
34	$testvalue[]=&$array;
35	var_dump ($testvalue);
36}
37
38
39echo "\nDone";
40?>
41--EXPECTF--
42*** Indexing - Testing value assignment with key ***
43array(1) {
44  ["foo"]=>
45  array(1) {
46    [0]=>
47    int(1)
48  }
49}
50
51Warning: Cannot use a scalar value as an array in %s on line %d
52int(0)
53
54Warning: Cannot use a scalar value as an array in %s on line %d
55int(1)
56
57Warning: Cannot use a scalar value as an array in %s on line %d
58bool(true)
59array(1) {
60  ["foo"]=>
61  array(1) {
62    [0]=>
63    int(1)
64  }
65}
66array(1) {
67  ["foo"]=>
68  array(1) {
69    [0]=>
70    int(1)
71  }
72}
73
74Warning: Illegal string offset 'foo' in %s on line %d
75
76Notice: Array to string conversion in %s on line %d
77string(1) "A"
78
79Warning: Cannot use a scalar value as an array in %s on line %d
80float(0.1)
81array(1) {
82  ["foo"]=>
83  array(1) {
84    [0]=>
85    int(1)
86  }
87}
88
89*** Indexing - Testing reference assignment with key ***
90array(1) {
91  ["foo"]=>
92  &array(1) {
93    [0]=>
94    int(1)
95  }
96}
97
98Warning: Cannot use a scalar value as an array in %s on line %d
99int(0)
100
101Warning: Cannot use a scalar value as an array in %s on line %d
102int(1)
103
104Warning: Cannot use a scalar value as an array in %s on line %d
105bool(true)
106array(1) {
107  ["foo"]=>
108  &array(1) {
109    [0]=>
110    int(1)
111  }
112}
113array(1) {
114  ["foo"]=>
115  &array(1) {
116    [0]=>
117    int(1)
118  }
119}
120
121Warning: Cannot use a scalar value as an array in %s on line %d
122float(0.1)
123array(1) {
124  ["foo"]=>
125  &array(1) {
126    [0]=>
127    int(1)
128  }
129}
130*** Indexing - Testing value assignment no key ***
131array(1) {
132  [0]=>
133  array(1) {
134    [0]=>
135    int(1)
136  }
137}
138
139Warning: Cannot use a scalar value as an array in %s on line %d
140int(0)
141
142Warning: Cannot use a scalar value as an array in %s on line %d
143int(1)
144
145Warning: Cannot use a scalar value as an array in %s on line %d
146bool(true)
147array(1) {
148  [0]=>
149  array(1) {
150    [0]=>
151    int(1)
152  }
153}
154array(1) {
155  [0]=>
156  array(1) {
157    [0]=>
158    int(1)
159  }
160}
161
162Warning: Cannot use a scalar value as an array in %s on line %d
163float(0.1)
164array(1) {
165  [0]=>
166  array(1) {
167    [0]=>
168    int(1)
169  }
170}
171
172*** Indexing - Testing reference assignment no key ***
173array(1) {
174  [0]=>
175  &array(1) {
176    [0]=>
177    int(1)
178  }
179}
180
181Warning: Cannot use a scalar value as an array in %s on line %d
182int(0)
183
184Warning: Cannot use a scalar value as an array in %s on line %d
185int(1)
186
187Warning: Cannot use a scalar value as an array in %s on line %d
188bool(true)
189array(1) {
190  [0]=>
191  &array(1) {
192    [0]=>
193    int(1)
194  }
195}
196array(1) {
197  [0]=>
198  &array(1) {
199    [0]=>
200    int(1)
201  }
202}
203
204Warning: Cannot use a scalar value as an array in %s on line %d
205float(0.1)
206array(1) {
207  [0]=>
208  &array(1) {
209    [0]=>
210    int(1)
211  }
212}
213
214Done