duanjing9339 2018-02-14 00:46
浏览 192
已采纳

生成唯一ID [重复]

This question already has an answer here:

I am looking for the most reliable way to generate unique ids for a project where users can post content without getting duplicates. When the post is submitted I would like to generate a unique id for it to be referenced back to. Such as when loaded from a shared link which might look like

example.com/post/e8a42f290fd853daa666aeaefa607f42

Except I rather have shorter links.

The ids will probably be a combination of a user's username and the current time.

Although there are similar questions I haven't found one that provide answers that I think are best, most suggest using md5 then trim it down, except that would higher the chances of the same string being generated.

Edit:

I am not using auto increment because it will become harder to scale later on.

</div>
  • 写回答

1条回答 默认 最新

  • dongxieyi9115 2018-02-14 00:49
    关注

    Have you looked into uniqid()?

    http://php.net/manual/en/function.uniqid.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能