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

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

WBOY
WBOYOriginal
2016-07-25 08:57:461283browse
  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.



Statement:
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