这就是php的工作原理.如果不在if语句周围放置括号,则只有下一个语句位于if块中,所有其他后续语句都不在其中.但是,由于你之后有一个else块,你会收到一个错误.
(顺便说一下:你在if块中做了一个赋值,所以这将永远是真的)
看看这两个例子:
if($this->reel3 = 1)
parent::addCash($this->$bet*2); //In the if statement
print(parent::getCash()); //Outside the if statement
else
与…一样:
if($this->reel3 = 1) {
parent::addCash($this->$bet*2);
}
print(parent::getCash());
//^^^^^ I think here it's more clear to see that this will give you a error, since it's between the if and else block which is not allowed
else { }