Notice: Uninitialized string offset in PHP -
Hello, I have this function and it returns a notice:
Notice: Unscrupited string offsets:
The affected line is: I have tried to do with braces and it does not work. If someone can tell some suggestion, then I appreciate it. Thank you. You can sometimes sometimes overwrite due to Because you are randomly selected, you do not always get the information - it only happens when function generator and $ ($ length) {$ string = ''; $ Letters = "0123456789abcdef"; ($ P = 0; $ p & lt; $ length; $ p ++) {$ string = $ Letters [mt_rand (0, strlen ($ letters)); } Return $ string; }
$ string. = $ Letters [mt_rand (0, strlen ($ letters)];
$ letter strlen ($ Character) , which should be
strlen ($ letters) - 1 . Your random series should start with zero, and you have to end with a zero length if the
$ character is 10, then the last zero-based array index < Em> nine , and it keeps up your upper limit for random selection.
$ string = ''; $ Letters = "0123456789abcdef"; ($ P = 0; $ p & lt; $ length; $ p ++) {$ string = $ Characters [mt_rand (0, strlen ($ letters) - 1)]; }
mt_rand () returns its maximum value at any point In your loop
Comments
Post a Comment