Users.php(模型):從模型中使用功能
...
public function hashPassword($password){
$hashed = hash('sha256', $password . self::HASH_CODE);
return $hashed;
}
...
UserIdentity.php
...
else if($user->password!==Users::hashPassword($this->password))
...
錯誤:
Non-static method Users::hashPassword() should not be called statically, assuming $this from incompatible context
讓它變成靜態是最好的方法嗎? –
@LucianoNascimento由於該方法的目的,是的 - 它看起來像是一個很好的靜態候選人。 – newfurniturey