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()); 21 22var_dump(shm_get_var(-1, -1)); 23 24var_dump(shm_get_var($s, 1000)); 25var_dump(shm_get_var($s, -10000)); 26 27var_dump(shm_get_var($s, array())); 28var_dump(shm_get_var($s, -1)); 29var_dump(shm_get_var($s, 0)); 30var_dump(shm_get_var($s, 1)); 31var_dump(shm_get_var($s, 2)); 32var_dump(shm_get_var($s, 3)); 33 34shm_put_var($s, 3, "test"); 35shm_put_var($s, 3, 1); 36shm_put_var($s, 3, null); 37 38var_dump(shm_get_var($s, 3)); 39shm_remove($s); 40 41echo "Done\n"; 42?> 43--EXPECTF-- 44Warning: shm_get_var() expects exactly 2 parameters, 0 given in %s005.php on line %d 45NULL 46 47Warning: shm_get_var() expects parameter 1 to be resource, int given in %s005.php on line %d 48NULL 49 50Warning: shm_get_var(): variable key 1000 doesn't exist in %s005.php on line %d 51bool(false) 52 53Warning: shm_get_var(): variable key -10000 doesn't exist in %s005.php on line %d 54bool(false) 55 56Warning: shm_get_var() expects parameter 2 to be int, array given in %s005.php on line %d 57NULL 58string(11) "test string" 59object(stdClass)#%d (0) { 60} 61array(3) { 62 [0]=> 63 int(1) 64 [1]=> 65 int(2) 66 [2]=> 67 int(3) 68} 69bool(false) 70NULL 71NULL 72Done 73