我想更改此代碼示例,以便同時評估所有這些條件。如果多個條件爲真,則可以將多個參數傳遞給'註冊'功能。使用PHP一次評估多個條件
我最初嘗試使用開關,但每個條件都需要能夠評估不同的條件。
任何幫助指向我在這個正確的方向將是偉大的。
if ($this->form_validation->run() == FALSE) {
$this->signup();
} else if ($this->membership_model->check_field('username',$this->input->post('username'))) {
$this->signup("An account with the username you've entered already exists.");
} else if ($this->membership_model->check_field('email_address',$this->input->post('email_address'))) {
$this->signup("An account with the e-mail you've entered already exists.");
}
你也可以查看[設置表單驗證錯誤](http://codeigniter.com/user_guide/libraries/form_validation.html#settingerrors)。 – Zombaya 2012-04-28 23:22:29
Thx。這看起來很不錯。使用func_get_args();在註冊函數中,當傳遞errors數組時,每個項目都會讀取單個參數或單個數組。 – jsuissa 2012-04-28 23:24:30
你應該檢查文檔或者只是測試它(例如用var_dump())。你也可以給signup()一個參數。似乎很奇怪在那裏使用func_get_args()。 – Zombaya 2012-04-28 23:28:21