Sanaullah Sajid Mukhtiar

How generate a tokens, unique random numbers string in php

How would it be possible to generate a random,unique string using numbers and letters for use in a verify link and other use?
Yes it Possible in different way.

This function will generate a random key using numbers and letters:

< ?php

//there are 10 is length of token.You can change it..
function token($length = 10) {
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, $charactersLength - 1)];
    return $randomString;
//token() for function call and store in $token
$token =  token();
//print $token
echo $token;
//output example
// ZlahOKxYpw
? >