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

php中or ,and的作用及使用

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:57:47
Original
1567 people have browsed it

关于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:
source:php.cn
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template