日期:2014-05-17  浏览次数:20406 次

怎么有人说用md5生成唯一id呢?
由于基于系统时间,通过该函数生成的 ID 不是最佳的。如需生成绝对唯一的 ID,请使用 md5() 函数(请在字符串函数参考中查找)。

有人推荐md5(uniqid(rand(), true));这样用.

如果uniqid不能保证绝对不重复, md5毫无作用啊? 因为md5依赖于输入, 和是否唯一无关啊.

------解决方案--------------------
你的理解是对的. 

手册上有这么一段注释, 看起来类似但是含义完全不同: (hmmm,这个中文版手册又滞后了,没有这段)

This function does not generate cryptographically secure tokens, in fact without being passed any additional parameters the return value is little different from microtime(). If you need to generate cryptographically secure tokens use openssl_random_pseudo_bytes().