此代码是我计划用于生成门票唯一代码的代码。
// A prefix to avoid uniqid collisions (when invoking this function at the same time).
// Should I use mt_rand or just rand?
$prefix = str_pad(dechex(mt_rand(0, 0xFFFFFF)), 6, '0', STR_PAD_LEFT);
// uniqid with more entropy enabled.
$unique_id = uniqid("$prefix-", TRUE);
// A SHA-1 hash for the generated code, this way it looks less sequential.
$unique_id = sha1($unique_id);
如果您能告诉我此代码中的问题,将会更有帮助。
提前谢谢。