PHP Assignment Operators

PHP assignment operators applied to assign the result of an expression to a variable. = is a fundamental assignment operator in PHP. It means that the left operand gets set to the value of the assignment expression on the right.

OperatorDescription
=Assign
+=Increments then assigns
-=Decrements then assigns
*=Multiplies then assigns
/=Divides then assigns
%=Modulus then assigns
Example:
<?php
  $var = "value";  // $var now contains the string "value"
  $var = 1;    // $var now contains the integer value 1
  $var += 3;    //$var now contains the integer 4
?>

Courses
Subscribe Updates via Email

Join 49,000+ W3schools lovers and get all the latest tutorials, programs, algorithms in your inbox.