Page 177 - TrackpadV5.1_class7
P. 177

Logical operators: They are used to combine multiple conditions and evaluate them. They
                   return a Boolean value 'True' or 'False' as output. Logical operators of PHP are AND(&&), OR (||),
                   XOR(^), NOT(!). Let us create a PHP script to use some of the logical operators.


                   <HTML>
                   <HEAD> <TITLE> Using Variables </TITLE> </HEAD>

                   <BODY>

                   <?php

                   $a = true;

                   $b = false;

                   echo var_dump($a and $b);
                   echo "<br>",var_dump($a or $b);

                   echo "<br>",var_dump($a xor $b);

                   ?>

                   </BODY>

                   </HTML>
                   Note that var_dump() function is used to evaluate the logical operators. We get the following
                   output when executing the preceding script:












































                                                                                                 Techipedia (PHP)  175
   172   173   174   175   176   177   178   179   180   181   182