What can you do without operators? Not much, if you're trying to do without them in a programming language, and PHP is no exception. On Monday, we barely had time to show you a long list of the operators in PHP. Today, we're going to show you what they do.
Logical operators are used to help test one or more criteria. The && operator says: if this and this are true, then do this. The || operator says: if this criteria OR that criteria is true, then do this. And finally the ! operator checks to see if a value is NOT true.
Oops I Did It Again
One thing I neglected to cover in the previous article was the use of quotes when using the echo function. This caused me to be beaten with many whips and locked in the basement with only episodes of Ugly Betty to keep me company. I know. I still haven't recovered.
When mixing HTML and PHP together be sure to follow these rules:
Do not use quotes inside of a string
Use the backslash to escape your quotes within a string
Both of the above are good examples of how to use quotes when mixing PHP and HTML.
Well, we covered a lot of ground this episode. Hopefully you have a decent grasp of how operators work. Don't worry if you aren't a master of them yet; that comes with practice.
In our next tutorial we will discuss the various Statements available in PHP and go more in-depth on the comparison and logical operators. So check back in. You might learn something.