PHP random string generator function
function generateRandomString($length = 10) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomStringValue = '';
for ($i = 0; $i < $length; $i++) {
$randomStringValue .= $characters[rand(0, strlen($characters) - 1)]; }
return $randomStringValue ;}
Output the random string :-
// Echo the random string.
echo generateRandomString();