PHP 语法惊喜与条件运算符 “?:” 和 “OR”
2022-08-30 23:31:23
今天,我被以下几点张开了嘴巴:
$asdf = ((1 OR true) ? "asdf" : "fdsa");
var_dump($asdf); // print "asdf"
$asdf = (1 OR true) ? "asdf" : "fdsa";
var_dump($asdf); // print "asdf"
$asdf = (1 OR true ? "asdf" : "fdsa");
var_dump($asdf); // print true
$asdf = 1 OR true ? "asdf" : "fdsa";
var_dump($asdf); // print 1
好吧,最后一个不会让我感到惊讶,但是第三个呢?谁能解释一下?