To Documents

Table of PHP Operators

 
  1. Arithmetic Operators

    Example Name Meaning
    $x + $y Addition Computes the sum of $x and $y.
    $x - $y Subtraction Computes the difference $x minus $y.
    $x * $y Multiplication Computes the product $x times $y.
    $x / $y Division Computes the floating point quotient $x divided by $y.
    $x % $y Mod Computes the remainder of $x divided by $y using integer division.

  2. Concatenation Operator

    Example Name Meaning
    $x . $y Concatenation Combines $x and $y into a single string.

  3. Assignment Operators

    Example Name Meaning
    $x = $y; Assignment Assign $x to $y.
    $x += $y; Plus Equal Replace $x by $x + $y.
    $x -= $y; Minus Equal Replace $x by $x - $y.
    $x *= $y; Times Equal Replace $x by $x * $y.
    $x /= $y; Divide Equal Replace $x by $x / $y.
    $x %= $y; Mod Equal Replace $x by $x % $y.
    $x .= $y; Concatenate Equal Replace $x by $x . $y.

  4. Comparison Operators

    Example Name Meaning
    $x == $y Equal To $x is equal to $y
    $x === $y Identical To $x is equal to $y and they are of the same datatype.
    $x != $y Not Equal To $x is not equal to $y
    $x <> $y Not Equal To $x is not equal to $y
    $x !== $y Not Identical To $x is not equal to $y or they are not of the same datatype
    $x < $y Less Than $x is strictly less than $y
    $x <= $y Less Than or Equal $x is less than or equal to $y
    $x > $y Greater Than $x is strictly greater than $y
    $x >= $y Equals $x is greater than or equal to $y

  5. Logical Operators

    Example Name Meaning
    $x and $y Logical And Returns TRUE if both $x and $y are TRUE, otherwise FALSE.
    $x or $y Logical Or Returns TRUE if $x or $y or both are TRUE, otherwise FALSE.
    $x xor $y
     
    Logical Exclusive Or
     
    Returns TRUE if $x or $y but not both are TRUE,
    otherwise FALSE.
    !$x Logical Not Returns FALSE if $x is TRUE, otherwise TRUE.
    $x && $y Logical And Returns TRUE if both $x and $y are TRUE, otherwise FALSE.
    $x || $y Logical OR Returns TRUE if $x or $y or both TRUE, otherwise FALSE.

    Note that even though and has the same meaning as && and or has the same meaning as ||, they have different precedences.