PHP Operators - Logical Operators
(Page 6 of 6 )
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
Use the single quote
Never feed them after midnight
Here is an example:
<html>
<body>
<?php
echo “<h1 class=”yourH1”>Hello Fatty Boom Balatty</h1>;
echo “<h1 class='yourH1'>Hello Fatty Boom Balatty</h1>
?>
</body>
</html>
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.
Till then...
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |