xref: /PHP-8.2/Zend/tests/resource_key.phpt (revision 776726da)
1--TEST--
2Behavior of resources as array keys
3--FILE--
4<?php
5
6$r = fopen(__FILE__, 'r');
7$a = [];
8echo "Assign:";
9$a[$r] = 1;
10echo "Add assign:";
11$a[$r] += 1;
12echo "Inc:";
13$a[$r]++;
14echo "Get:";
15var_dump($a[$r]);
16echo "Isset:";
17var_dump(isset($a[$r]));
18echo "Unset:";
19unset($a[$r]);
20
21?>
22--EXPECTF--
23Assign:
24Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
25Add assign:
26Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
27Inc:
28Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
29Get:
30Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
31int(3)
32Isset:
33Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
34bool(true)
35Unset:
36Warning: Resource ID#%d used as offset, casting to integer (%d) in %s on line %d
37