Uninitialized string offset
<pre><code>protected static function generateString ($length = 50, $Password){
        $characters = $Password;
        $string = '';

        for ($p = 0; $p &lt; $length; $p++) {
            $string .= $characters[mt_rand(0, strlen($characters))]; // Error Line
        }
        echo $string;
    }
</code></pre>

<p>Hello. I am building an authentication class, and the function above is giving me some  grief, I keep getting presented with the error message: </p>

<blockquote>
  <p>Notice: Uninitialized string offset: 16</p>
</blockquote>

<p>The echo is there for testing purposes. </p>

<p>I am calling my function using: </p>

<pre><code> public static function Compile($Password, $Length){
        self::generateString($Length,$Password);
    }

Auth::Compile('testi ngpassword', 10);
</code></pre>

<p>When I run my script, sometimes it generates with no error message; but when running multiple times (3- 7) I get presented with the message as specified above? and sometimes this notice shows over two lines?</p>

<p>So why is it the error message is getting generated randomly when repeatedly running? when the arguments specified is not changing?</p>
