Home  >  Article  >  Backend Development  >  php中or ,and的作用及使用

php中or ,and的作用及使用

WBOY
WBOYOriginal
2016-06-23 13:57:471529browse

关于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  }




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn