当前位置:Gxlcms > PHP教程 > php中or,and的功用及使用

php中or,and的功用及使用

时间:2021-07-01 10:21:17 帮助过:27人阅读

php中or ,and的作用及使用

关于or,and的使用,查资料得知:and相当于then,or相当于else

下面通过举例来理解这两个关键字的使用:

比如:【1】

$isRight or $a=1000;

他与下面这段代码是等价的:

if(isRight==true){}else{ $a=1000;}

【2】

$update and $db_factory=1;

等价于:

 if($update==true){   $db_factory=1;}

【3】

$aa and $b=1 or $c=1

等价于:

if ($aa){    $b=1 }else{ $c=1  }




人气教程排行