This is my static function to generate a random string:
public static function generateCode($salt)
{
$this->generate = substr(hash('sha512', $salt), 0, 15);
return $this->generate;
}
And that's how I use it:
$this->insert->execute(array(
":username" => $username,
"generated_code" => self::generateCode($email)
));
I have declared the property:
protected $generate;
Getting this error:
Fatal error: Using $this when not in object context in C:\xampp\htdocs\drip\class\users.class.php on line 154
Line 154:
$this->generate = substr(hash('sha512', $salt), 0, 15);
What's wrong with this? Why is it giving me that error?
$this
does not exist in static functions. They only exist in class context, there is no object instance