我想更改此代码示例,以便同时评估所有这些条件。如果多个条件为真,则可以将多个参数传递给'注册'功能。使用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