xref: /PHP-8.0/ext/sysvshm/tests/005.phpt (revision d1764ca3)
1--TEST--
2shm_get_var() tests
3--SKIPIF--
4<?php
5if (!extension_loaded("sysvshm")){ print 'skip'; }
6if (!function_exists('ftok')){ print 'skip'; }
7?>
8--FILE--
9<?php
10
11$key = ftok(__FILE__, 't');
12$s = shm_attach($key, 1024);
13
14shm_put_var($s, -1, "test string");
15shm_put_var($s, 0, new stdclass);
16shm_put_var($s, 1, array(1,2,3));
17shm_put_var($s, 2, false);
18shm_put_var($s, 3, null);
19
20var_dump(shm_get_var($s, 1000));
21var_dump(shm_get_var($s, -10000));
22
23var_dump(shm_get_var($s, -1));
24var_dump(shm_get_var($s, 0));
25var_dump(shm_get_var($s, 1));
26var_dump(shm_get_var($s, 2));
27var_dump(shm_get_var($s, 3));
28
29shm_put_var($s, 3, "test");
30shm_put_var($s, 3, 1);
31shm_put_var($s, 3, null);
32
33var_dump(shm_get_var($s, 3));
34shm_remove($s);
35
36echo "Done\n";
37?>
38--EXPECTF--
39Warning: shm_get_var(): Variable key 1000 doesn't exist in %s005.php on line %d
40bool(false)
41
42Warning: shm_get_var(): Variable key -10000 doesn't exist in %s005.php on line %d
43bool(false)
44string(11) "test string"
45object(stdClass)#%d (0) {
46}
47array(3) {
48  [0]=>
49  int(1)
50  [1]=>
51  int(2)
52  [2]=>
53  int(3)
54}
55bool(false)
56NULL
57NULL
58Done
59