Following is the function which provide random string… but i’m getting this error message
Notice: Undefined variable: str in C:\xampp\htdocs\webrootfinal\forgotpasspr.php on line 5………
function rand_string( $length ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$size = strlen( $chars );
for( $i = 0; $i < $length; $i++ ) {
$str.= $chars[ rand( 0, $size - 1 ) ];
}
return $str;
}
$my_string = rand_string( 10 );
Any Idea or Solution…
Give
$stra value before you start concatenating to it.