【发布时间】:2010-04-19 17:08:30
【问题描述】:
我正在查看 Kohana 3 中的 auth 类以及登录脚本。当登录页面调用auth类的登录函数时,通过一个受保护的抽象函数_login返回。你为什么会出于好奇而这样做?我似乎无法理解真正有什么区别,因为无论哪种方式你都会返回相同的数据。在我脑海中浮现的一个选项是,通过受保护的摘要返回,您将确保数据从被放入 auth->login 函数和离开它的时间起没有被修改。我试图理解其中的一些细微差别。谢谢。
public function login($username, $password, $remember = FALSE)
{
if (empty($password))
return FALSE;
if (is_string($password))
{
// Get the salt from the stored password
$salt = $this->find_salt($this->password($username));
// Create a hashed password using the salt from the stored password
$password = $this->hash_password($password, $salt);
}
return $this->_login($username, $password, $remember);
}
然后……
abstract protected function _login($username, $password, $remember);
【问题讨论】: