【发布时间】:2011-03-02 09:21:57
【问题描述】:
可能重复:
What is the PHP ? : operator called and what does it do?
我像个傻瓜一样喂食,但我不完全理解这段代码中发生了什么:
$var .= ($one || $two) ? function_one( $one, $another) : function_two( $two, $another);
这是否说明如果 $one 或 $two 则 $var 等于 fuction_one(),否则为 function_two()?使用这种语法的目的是什么——速度?
【问题讨论】:
-
这是关闭的,但关于它的用途 - 速度和更清洁的代码,如本例所示:en.wikipedia.org/wiki/Conditional_operator#Usage
-
感谢大家的热烈响应!
-
对于它的价值,如果您的问题是“这是什么?”,那么很难确定您的问题是否重复。
标签: php