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.
Operator | Description |
---|---|
= | 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
?>