开发者

explain a snippet [duplicate]

开发者 https://www.devze.com 2023-02-18 02:54 出处:网络
This question already has answers 开发者_StackOverflow社区here: Closed 11 years ago. Possible Duplicate:
This question already has answers 开发者_StackOverflow社区here: Closed 11 years ago.

Possible Duplicate:

Reference - What does this symbol mean in PHP?

What is the ?: Operator and what does it do?

The three different equals (=, ==, ===)

Can some explain how this works?

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


It is a alternative if else construction.

You can write it also like:

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


it´s the same as

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

精彩评论

暂无评论...
验证码 换一张
取 消