xref: /PHP-7.3/Zend/tests/offset_array.phpt (revision 782352c5)
1--TEST--
2using different variables to access array offsets
3--FILE--
4<?php
5
6$arr = array(1,2,3,4,5,6,7,8);
7
8var_dump($arr[1]);
9var_dump($arr[0.0836]);
10var_dump($arr[NULL]);
11var_dump($arr["run away"]);
12
13var_dump($arr[TRUE]);
14var_dump($arr[FALSE]);
15
16$fp = fopen(__FILE__, "r");
17var_dump($arr[$fp]);
18
19$obj = new stdClass;
20var_dump($arr[$obj]);
21
22$arr1 = Array(1,2,3);
23var_dump($arr[$arr1]);
24
25echo "Done\n";
26?>
27--EXPECTF--
28int(2)
29int(1)
30
31Notice: Undefined index:  in %s on line %d
32NULL
33
34Notice: Undefined index: run away in %s on line %d
35NULL
36int(2)
37int(1)
38
39Notice: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
40int(%d)
41
42Warning: Illegal offset type in %s on line %d
43NULL
44
45Warning: Illegal offset type in %s on line %d
46NULL
47Done
48