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