xref: /PHP-8.1/Zend/tests/isset_array.phpt (revision b8e380ab)
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)
41
42Deprecated: Implicit conversion from float 0.6 to int loses precision in %s on line %d
43bool(true)
44bool(false)
45bool(false)
46
47Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
48bool(false)
49Illegal offset type in isset or empty
50Illegal offset type in isset or empty
51