public function authenticate() { $user=User::model()->find('LOWER(username)=?',array(strtolower($this->username))); if($user===null) $this->errorCode=self::ERROR_USERNAME_INVALID; else if(!$user->validatePassword($this->password)) $this->errorCode=self::ERROR_PASSWORD_INVALID; else { $this->_id=$user->id; $this->username=$user->username; $this->errorCode=self::ERROR_NONE; } return $this->errorCode==self::ERROR_NONE; }
yii demo裏的authenticate函數,這裏條件邏輯執行過程當中,retuan 語句是在前面的if和else if 都不成立,最後一個else成立的時候才retuan.並非每執行一個條件都retuan.php
好奇怪的條件邏輯語法, 學習了!
yii