I am writing a Authentication class in PHP and when i have the following function,
private function randomString($length = 50) {
$characters = "1234567890abcdefghijklmnopqrstuvwxyz";
$string = '';
for ($p=0; $p < $length; $p++) {
$string .= $characters[mt_rand(0, strlen($characters))];
}
return $string;
}
i get the following error:
Notice: Uninitialized string offset: 36
I am new to creating classes so i don't know what i have done wrong here. or is there a better method of generating a random string?