php logical operators

伊谢尔伦
Release: 2016-11-24 13:27:40
Original
1451 people have browsed it

Logical Operator

Example                                                                                                                      b And (logical AND) TRUE if $a and $b are both TRUE. $a or $b Or (logical OR) TRUE, if either $a or $b is TRUE. $a xor $b Xor (logical exclusive OR) TRUE, if either $a or $b is TRUE, but not both at the same time.

! $a Not (logical not) TRUE, if $a is not TRUE.

$a && $b And (logical AND) TRUE, if $a and $b are both TRUE.

$a || $b Or (logical OR) TRUE, if either $a or $b is TRUE. ​

The reason why "AND" and "OR" have two different forms of operators is that the priorities of their operations are different (see Operator Priority).

Example #1 Logical Operator Example

Copy after login

The output of the above routine is similar to:

bool(true)
bool(false)
bool(false)
bool(true)
Copy after login

Related labels:
php
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!