脚本宝典收集整理的这篇文章主要介绍了PHP包含较少的IF条件不接受多个语句,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
如果您有其他任何其他替代语法的链接,请告诉我.
贝娄只是我从项目中粘贴的东西和语法错误的例子.
if($this->reel3 = 1) parent::addCash($this->$bet*2); PRint(parent::getCash()); // < Line throwing the Syntax error else // TODO
编辑(FURTHERMORE)
在看了一些答案和评论后,我想知道它是如何在专业环境中完成的,我知道这更多是关于品味,但我想从专业人士那里知道语法的风格是否重要?
将
if(condITion) { //something } else { //something }
比…更好
if(condition): //something else: //something endif;
或任何其他方式编写相同的代码?
(顺便说一下:你在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 { }
有关控制结构的更多信息,请参见手册:http://php.net/manual/en/control-structures.if.php
以上是脚本宝典为你收集整理的PHP包含较少的IF条件不接受多个语句全部内容,希望文章能够帮你解决PHP包含较少的IF条件不接受多个语句所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。