<HTML ><HEAD ><TITLE >Logical Operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Operators" HREF="language.operators.html"><LINK REL="PREVIOUS" TITLE="Incrementing/Decrementing Operators" HREF="language.operators.increment.html"><LINK REL="NEXT" TITLE="Operator Precedence" HREF="language.operators.precedence.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP Manual</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="language.operators.increment.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 10. Operators</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.operators.precedence.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.operators.logical" >Logical Operators</A ></H1 ><DIV CLASS="table" ><P ><B >Table 10-5. Logical Operators</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >example</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >name</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >result</TH ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a and $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >And</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if both $a and $b are true.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a or $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Or</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if either $a or $b is true.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a xor $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Or</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if either $a or $b is true, but not both.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >! $a</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Not</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if $a is not true.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a && $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >And</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if both $a and $b are true.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a || $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Or</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >True if either $a or $b is true.</TD ></TR ></TABLE ></DIV ><P > The reason for the two different variations of "and" and "or" operators is that they operate at different precedences. (See <A HREF="language.operators.precedence.html" >Operator Precedence</A >.) </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="language.operators.increment.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.operators.precedence.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Incrementing/Decrementing Operators</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="language.operators.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Operator Precedence</TD ></TR ></TABLE ></DIV ></BODY ></HTML >