Home arrow PHP arrow PHP Operators

PHP Operators

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

In our last tutorial I left you with a giant table full of operators to study. But I know you, and you are a slacker, so instead of making you go back to that previous article like I should, I am going to spot you one and post it here for you again. That and well...it helps increase my word count. All hail laziness!

 

Symbol

What it Does

Type

+

Used for Addition

Arithmetic

-

Used for Subtraction

Arithmetic

*

Used for Multiplication

Arithmetic

/

Used for Dividing

Arithmetic

%

Used for Modulation

Arithmetic

++

Used to increase value by one

Arithmetic

--

Used to decrease value by one

Arithmetic

“=”

Used to Assign a Value

Assignment

+=

Used to Add and Assign a Value

Assignment

-=

Used to Subtract and Assign a Value

Assignment

*=

Used to Multiply and Assign a Value

Assignment

/=

Used to Divide and Assign a Value

Assignment

.=

String Concatenation

Assignment

%=

Used to Modulate and Add a Value

Assignment

“==”

Equal To

Comparison

!=

Not Equal To

Comparison

>

Greater Than

Comparison

<

Less Than

Comparison

>=

Greater Than or Equal To

Comparison

<=

Less Than or Equal To

Comparison

&&

This is the Logical (AND) Operator that Returns a True Value if All Expressions Being Checked Are True

Logical

||

This is the Logical (OR) Operator that Returns a True Value if Any of the Expressions Being Checked Are True

Logical

!

This is the Logical (NOT) Operator that Returns a True Value if the Expression Being Checked Is Not True

Logical

So there you go. No, you aren't having deja vu. That's just a glitch in the Matrix. Like the third part in that movie series. I mean, way to ruin a trilogy. Let's create a third movie and then have the main characters, who have been the focus of the previous two movies, only be in the final installment for like 20 minutes. Don't get me started.

Okay where was I?



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

blog comments powered by Disqus
   

PHP ARTICLES

- 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...
- PHP: Building Concrete Validators
- Sanitizing Input with PHP
- Executing Shell Commands with PHP
- Handling File Data with PHP
- File Security and Resources with PHP
- ArrayObject PHP Class Examples
- ArrayObject PHP Class: An Introduction
- Getting File System Data with PHP
- PHP Tools for Working with the File and Oper...
- Working with the File and Operating System w...
- PHP Proxy Patterns: Completing a Blog


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap

Dev Shed Tutorial Topics: