Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

Start Learning Now

Our free lessons will get you started (Flash® 10 required).
Get immediate access to our entire library.

Sign up for Educator.com

Features Overview

  • Get on-demand access to our complete library
  • Search and jump to exactly what you need to learn
  • Track your progress
  • Download practice and lesson files
  • *Ask questions and get answers from our community & instructors

Logical & Ternary Operators

  • Logical operators are used to create complex boolean expressions and operate on boolean operands. PHP’s logical operators are:
    • NOT ( ! ) – unary operator that returns TRUE if its operand is FALSE
    • OR ( || , or ) – binary operators that return TRUE if either operands are TRUE
    • AND ( && , and ) – binary operators that return TRUE only if both operands are TRUE
    • XOR ( xor ) – binary operator that returns TRUE if either operand is TRUE , but not both
  • The OR and AND logical operators have two options because the options have different precedence:
    • || has a higher precedence than or
    • && has a higher precedence than and
  • The OR and AND logical operators are known as short-circuit operators meaning that if the value of their left operand can determine the result of the operation, the right operand never gets evaluated.
  • The ternary operator is the only ‘ternary’, or three-operand, operator in PHP. If a ternary operator’s 1st operand evaluates to TRUE , then the value of the 2nd operand is the result of the operation, otherwise the value of the 3rd operand is the result of the operation.
  • Additional Resources:

Logical & Ternary 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.

Computer Science: Introduction to PHP