开发者

How to generate unique numbers/IDs without duplicates? [duplicate]

开发者 https://www.devze.com 2023-03-16 15:02 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: PHP: How to generate a random, unique, alphanumeric string?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

PHP: How to generate a random, unique, alphanumeric string?

I wish to generate Product Keys or Licenses using PHP. Is there a function that allow me to do generate unique numbers/IDs but at the same time make sure that there won't 开发者_运维百科be a chance for duplicate?

Thank you.


You could use php's uniqid function to generate id's:

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

or leave that responsibility to the database engine, which will generate auto-incremented id values.


Use a uniqid


You can use md5(timestamp), its always unique

0

精彩评论

暂无评论...
验证码 换一张
取 消