本文介绍了PHP:如何生成用于随机链接的随机,唯一的字母数字字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用数字和字母生成一个随机,唯一的字符串以用于验证链接?就像您在网站上创建帐户一样,它会向您发送一封带有链接的电子邮件,您必须单击该链接才能验证您的帐户
How would it be possible to generate a random, unique string using numbers and letters for use in a verify link? Like when you create an account on a website, and it sends you an email with a link, and you have to click that link in order to verify your account
如何使用PHP生成其中之一?
How can I generate one of those using PHP?
推荐答案
如果您不希望它随着时间的流逝而变得绝对独特:
If you do not need it to be absolutely unique over time:
md5(uniqid(rand(), true))
否则(假设您已经为用户确定了唯一的登录名):
Otherwise (given you have already determined a unique login for your user):
md5(uniqid($your_user_login, true))
这篇关于PHP:如何生成用于随机链接的随机,唯一的字母数字字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!