11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 3 • <strong>PHP</strong> BASICSwww.it-ebooks.infoLogical OperatorsMuch like the arithmetic operators, logical operators (see Table 3-9) will probably play a major role inmany of your <strong>PHP</strong> applications, providing a way to make decisions based on the values of multiplevariables. Logical operators make it possible to direct the flow of a program and are used frequently withcontrol structures such as the if conditional and the while and for loops.Logical operators are also commonly used to provide details about the outcome of other operations,particularly those that return a value:file_exists("filename.txt") OR echo "File does not exist!";One of two outcomes will occur:• The file filename.txt exists.• The sentence “File does not exist!” will be output.Table 3-9. Logical OperatorsExample Label Outcome$a && $b AND True if both $a and $b are true$a AND $b AND True if both $a and $b are true$a || $b OR True if either $a or $b is true$a OR $b OR True if either $a or $b is true!$a NOT True if $a is not trueNOT $a NOT True if $a is not true$a XOR $b Exclusive OR True if only $a or only $b is trueEquality OperatorsEquality operators (see Table 3-10) are used to compare two values, testing for equivalence.72

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!