xref: /PHP-8.0/Zend/tests/isset_array.phpt (revision 14bdb0cf)
1--TEST--
2Using isset() with arrays
3--FILE--
4<?php
5
6$array = [
7    0 => true,
8    "a" => true,
9];
10
11var_dump(isset($array[0]));
12
13var_dump(isset($array["a"]));
14
15var_dump(isset($array[false]));
16
17var_dump(isset($array[0.6]));
18
19var_dump(isset($array[true]));
20
21var_dump(isset($array[null]));
22
23var_dump(isset($array[STDIN]));
24
25try {
26    isset($array[[]]);
27} catch (TypeError $exception) {
28    echo $exception->getMessage() . "\n";
29}
30
31try {
32    isset($array[new stdClass()]);
33} catch (TypeError $exception) {
34    echo $exception->getMessage() . "\n";
35}
36?>
37--EXPECTF--
38bool(true)
39bool(true)
40bool(true)
41bool(true)
42bool(false)
43bool(false)
44
45Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
46bool(false)
47Illegal offset type in isset or empty
48Illegal offset type in isset or empty
49