我正在使用codeigniter表单验证。要显示表单错误,它使用这个如何将此语法转换为正常的php if else
$this->data['message'] = (validation_errors() ?
validation_errors() :
($this->auth_lib->errors() ?
$this->auth_lib->errors() :
$this->session->flashdata('message')))
我不明白这个语法。我认为这是一个if else的陈述。这很难理解。
任何人都可以将其转换为正常的if else语句吗?
因为我现在要改变错误信息格式:
$this->message->set_error($msg=array('Test 1','Test 2'));
$message=$this->message->get_message();
$this->data['message']=$message;
任何人,请简化的语法。谢谢。
这不是来自CI,而是PHP本身:[ternary operator](http://www.php.net/manual/en/language.operators。 comparison.php#language.operators.comparison.ternary) – NullUserException
这就是为什么我讨厌三元经营者,除非它是非常短的东西。 – Matt
一旦你开始使用三元条件运算符,你会学会去爱它! :d – zombat