PHP script to generate a random string of AplhaNumeric values of given length

Script:

<?php
function generateRandomString($length = 64) {
    $characters = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
    $randomString = ”;
    for ($i = 0; $i < $length; $i++) {
        $randomString .= $characters[rand(0, strlen($characters) – 1)];
    }
    return $randomString;
}
echo generateRandomString();
?>

 

Output:

<

p>image

Leave a Reply

Your email address will not be published. Required fields are marked *