Loading video...
Expression & Operators
- An expression is anything in PHP that has a value.
- An operator takes one or more expressions, called operands , and performs some operation on them to yield another expression.
- Operators can be divided according to how many values they operate on:
- unary operators: single value
- binary operators: two values
- ternary operators: three values
- Assignment operators (=, =>) are binary operators used to assign the value of one expression to another expression .
- There are arithmetic operators for addition, subtraction, multiplication, division, and negation. There is also the modulus (%) operator used for getting the remainder of a division operation.
- The increment/decrement operators are used to increment or decrement their operand by one. They come in both pre and post forms.
- The concatenation operator (.) is used to combine two strings into one.
- PHP provides combined assignment operators for all of the binary arithmetic operators, as well as the concatenation operator.
- Operators have both a precedence and associativity .
- When an expression contains multiple operations, the operations with higher precedence are completed first. If an expression contains two operations of equal precedence , then the associativity of the operations determines which operation is completed first.
- Additional Resources:
Expression & Operators
Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.
- Intro
- Lesson Overview
- Expressions
- Operators
- Assignment Operators
- Arithmetic Operators
- Increment/Decrement Operators
- Combined Assignment Operators
- String Operators
- Precedence & Associativity
- Precedence & Associativity
- Expression Containing Multiple Operations
- Expression Containing Two Operations of Equal Precedence
- Using Parentheses to Force Precedence
- Precedence & Associativity Review
- Homework Challenge


































Start Learning Now
Our free lessons will get you started (Flash® 10 required).
Sign up for Educator.comGet immediate access to our entire library.
Features Overview