Reputation: 95
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...
Upvotes: 0
Views: 427
Reputation: 798716
Give $str
a value before you start concatenating to it.
Upvotes: 2