Home > Backend Development > PHP Tutorial > php中or ,and的功用及使用

php中or ,and的功用及使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 11:56:10
Original
2037 people have browsed it

php中or ,and的作用及使用

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

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

 比如:【1】

$isRight or $a=1000;
Copy after login

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

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

【2】

$update and $db_factory=1;
Copy after login

等价于:

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

【3】

$aa and $b=1 or $c=1
Copy after login

等价于:

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




Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template