Home arrow PHP arrow Page 6 - PHP Operators

Logical Operators - PHP

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.

TABLE OF CONTENTS:
  1. PHP Operators
  2. Assignment Operators
  3. Arithmetic Operators
  4. Incremental Operators
  5. Better by Comparison
  6. Logical Operators
By: James Payne
Rating: starstarstarstarstar / 20
October 31, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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...



 
 
>>> More PHP Articles          >>> More By James Payne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: