如何生成不固定长度的大随机数? (例如,在MySQL的bigint范围内)。 mt_rand()函数不支持这么大的数字。

最佳答案

使用多个随机函数:

const max_limit=10000;
a=mt_rand()*max_limit*max_limit + mt_rand()*max_limit + mt_rand();

关于php - 生成非固定长度的大随机数(bigint),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28071379/

10-16 23:15