In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Xiaobian to share with you what are the differences between php logical operators, I believe most people do not know how, so share this article for everyone's reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
Difference: 1, and and "&&" operators are used to indicate logical AND, and has lower priority,"&&" has higher priority;2, or and "||"Operators are used to indicate logical OR, or has lower precedence,"||The "$" operator is used to indicate logical NOT;4. The xor operator is used to indicate logical XOR.
Operating environment: Windows 10 system, PHP 7.1 version, Dell G3 computer.
What is the difference between PHP logical operators?
php logical operator
I always thought that "or" and "in PHP||"They can be equated, but they are not. There is a difference in priority. Here is an example of how they differ:
After execution,$a is true and $b is false. This is because "||"priority is greater than"=", execute false first|| true, and then assign the result true to $a after execution. If "or" has priority less than "=", assign false to $b first, so $b is false.
The logical AND operation in PHP has two forms: AND and &&, and the OR operation has OR and|| Two forms.
If two separate expressions are involved in an operation, the result of both forms is exactly the same, for example,$a AND $b and $a && $b are not different. Same $a OR $b and $a|| $b is exactly the same.
However, the two forms of logical operators have different priorities. The priorities of these four symbols are allowed from high to low: &&,||、AND、OR。Pay special attention to this sentence, which should be carefully understood. Examples:
$a || $b AND $c || $d
Equivalent to:
($a || $b) AND ($c || $d)
The above is "php logical operators what are the differences between" all the content of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.