<HTML ><HEAD ><TITLE >Logical Operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="PHP Manual" HREF="index.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="String Operators" HREF="language.operators.string.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation 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" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 11. Operators</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.operators.string.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.operators.logical" ></A >Logical Operators</H1 ><DIV CLASS="table" ><A NAME="AEN4691" ></A ><P ><B >Table 11-6. Logical Operators</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><THEAD ><TR ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Example</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Name</TH ><TH ALIGN="LEFT" VALIGN="MIDDLE" >Result</TH ></TR ></THEAD ><TBODY ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a and $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >And</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >TRUE</B ></TT > if both $a and $b are <TT CLASS="constant" ><B >TRUE</B ></TT >.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a or $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Or</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >TRUE</B ></TT > if either $a or $b is <TT CLASS="constant" ><B >TRUE</B ></TT >.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a xor $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Xor</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >TRUE</B ></TT > if either $a or $b is <TT CLASS="constant" ><B >TRUE</B ></TT >, 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" ><TT CLASS="constant" ><B >TRUE</B ></TT > if $a is not <TT CLASS="constant" ><B >TRUE</B ></TT >.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a && $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >And</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >TRUE</B ></TT > if both $a and $b are <TT CLASS="constant" ><B >TRUE</B ></TT >.</TD ></TR ><TR ><TD ALIGN="LEFT" VALIGN="MIDDLE" >$a || $b</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" >Or</TD ><TD ALIGN="LEFT" VALIGN="MIDDLE" ><TT CLASS="constant" ><B >TRUE</B ></TT > if either $a or $b is <TT CLASS="constant" ><B >TRUE</B ></TT >.</TD ></TR ></TBODY ></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.html#language.operators.precedence" >Operator Precedence</A >.) </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="language.operators.increment.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="language.operators.string.html" ACCESSKEY="N" >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" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >String Operators</TD ></TR ></TABLE ></DIV ></BODY ></HTML >