1--TEST-- 2Test uniqid() function : basic functionality 3--FILE-- 4<?php 5/* Prototype : string uniqid ([ string $prefix= "" [, bool $more_entropy= false ]] ) 6 * Description: Gets a prefixed unique identifier based on the current time in microseconds. 7 * Source code: ext/standard/uniqid.c 8*/ 9echo "*** Testing uniqid() : basic functionality ***\n"; 10 11echo "\nuniqid() without a prefix\n"; 12var_dump(uniqid()); 13var_dump(uniqid(null, true)); 14var_dump(uniqid(null, false)); 15echo "\n\n"; 16 17echo "uniqid() with a prefix\n"; 18 19// Use a fixed prefix so we can ensure length of o/p id is fixed 20$prefix = array ( 21 99999, 22 "99999", 23 10.5e2, 24 null, 25 true, 26 false 27 ); 28 29for ($i = 0; $i < count($prefix); $i++) { 30 var_dump(uniqid($prefix[$i])); 31 var_dump(uniqid($prefix[$i], true)); 32 var_dump(uniqid($prefix[$i], false)); 33 echo "\n"; 34} 35 36?> 37===DONE=== 38--EXPECTF-- 39*** Testing uniqid() : basic functionality *** 40 41uniqid() without a prefix 42string(13) "%s" 43string(23) "%s.%s" 44string(13) "%s" 45 46 47uniqid() with a prefix 48string(18) "99999%s" 49string(28) "99999%s.%s" 50string(18) "99999%s" 51 52string(18) "99999%s" 53string(28) "99999%s.%s" 54string(18) "99999%s" 55 56string(17) "1050%s" 57string(27) "1050%s.%s" 58string(17) "1050%s" 59 60string(13) "%s" 61string(23) "%s.%s" 62string(13) "%s" 63 64string(14) "1%s" 65string(24) "1%s.%s" 66string(14) "1%s" 67 68string(13) "%s" 69string(23) "%s.%s" 70string(13) "%s" 71 72===DONE=== 73