Home > Backend Development > PHP Tutorial > The difference between OR and || AND and && in php

The difference between OR and || AND and && in php

WBOY
Release: 2016-07-25 08:57:46
Original
1315 people have browsed it
  1. $p = 6 or 0;

  2. var_dump($p);//int(6)

  3. $p = 6 || 0;

  4. var_dump ($p);//bool(true)

  5. $p = 6 and 0;

  6. var_dump($p); //int(6)

  7. var_dump($p); //bool(false)

Copy code

Because the assignment operation has a higher priority than AND and OR, so first Assignment; is lower than && and ||, so logical operators are executed first, logical operations first, and then assignment.



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