PHP: How to generate a random, unique, alphanumeric string for use in a secret link?

后端 未结 28 2223
隐瞒了意图╮
隐瞒了意图╮ 2020-11-21 22:20

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 y

28条回答
  •  盖世英雄少女心
    2020-11-21 23:15

    If you want to generate a unique string in PHP, try following.

    md5(uniqid().mt_rand());
    

    In this,

    uniqid() - It will generate unique string. This function returns timestamp based unique identifier as a string.

    mt_rand() - Generate random number.

    md5() - It will generate the hash string.

提交回复
热议问题