解释一个片段

时间:2011-03-18 08:48:01

标签: php

  

可能重复:
  Reference - What does this symbol mean in PHP?
  What is the ?: Operator and what does it do?
  The three different equals (=, ==, ===)

有人可以解释一下这是如何运作的吗?

$xblgold = $xblgold == 1 ? "Yes" : "No";
echo $xblgold;

2 个答案:

答案 0 :(得分:0)

这是另一种if else构造。

你也可以这样写:

if($xblgold == 1) {
    $xblgold == "Yes";
} else {
    $xblgold == "No";
}

答案 1 :(得分:0)

相同
if($xblgold == 1){
   $xblgold = "Yes";
}else{
   $xblgold = "No";
}