Using $this when not in object context static function
<p>This is my static function to generate a random string:</p>

<pre><code>    public static function generateCode($salt)
    {
        $this-&gt;generate = substr(hash('sha512', $salt), 0, 15);
        return $this-&gt;generate;
    }
</code></pre>

<p>And that's how I use it:</p>

<pre><code>            $this-&gt;insert-&gt;execute(array(
            ":username" =&gt; $username,
            "generated_code" =&gt; self::generateCode($email)
            ));
</code></pre>

<p>I have declared the property:</p>

<pre><code>    protected $generate;
</code></pre>

<p>Getting this error:</p>

<pre><code>Fatal error: Using $this when not in object context in C:\xampp\htdocs\drip\class\users.class.php on line 154
</code></pre>

<p><strong>Line 154:</strong></p>

<pre><code>        $this-&gt;generate = substr(hash('sha512', $salt), 0, 15);
</code></pre>

<p><em><strong>What's wrong with this? Why is it giving me that error?</em></strong></p>
