创建唯一的跟踪代码
Possible Duplicate:
how is create a unique tracking code
With this function i can create a unique tracking code?
What is your suggestion?
<?php echo strtotime("now");?>
The number of characters not more than 10.
Please call example powerful
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
uniqid()
< 怎么样? /a> 函数?通过此功能,您获得唯一代码的机会比仅使用您在问题中所做的数据要好得多。
另外,您可能还想了解一下 GUID< /a> 是。
What about the
uniqid()
function ?With this functions, chances are far better for you to get a unique code than just using a data like you did in your question.
Also, you might want to take a look at what a GUID is.
这取决于您网站的目的...
一般来说,我还会添加用户IP。因此,如果两个人同时购买,就不会出现重叠。
It depends on the purpose of the your website...
In general, I would also add the user IP. so if two people are buying at the same time, you won't have an overlap.
如果两个用户完全相同的时间访问,那么他们将具有相同的跟踪代码。我建议使用 Unix 纪元作为 mt_rand() 函数的种子。
您还可以使用它(或仅使用它的一部分,例如毫秒)作为随机数的前缀或后缀。但这几乎可以模拟
uniquid()
的作用。显然播种是糟糕且无聊的(参见@Gumbo)。所以不要这样做。
If two users visit at exactly the same time, then they would have the same tracking code. I recommend using the Unix epoch as a seed for the
mt_rand()
function.You could also use it (or only a section of it, say the milliseconds) as a prefix or suffix to the random number. But that would pretty much emulate what
uniquid()
does.Apparently seeding is bad and boring (see @Gumbo). So don't do it.