PHP Assignment Operators
Description
The assignment operators set the values of variables either by copying the value or copying a reference to a value. They are shown in the following table.
PHP assignment operators
The following table lists the assignment operators used in PHP.
Operator | Name | Description |
---|---|---|
= | Assignment | $a = $b copies $b's value into $a |
=& | Reference | $a =& $b set $a to reference $b |
The following code shows how to use assignment operator to assign value to a variable.
<?PHP/*from w ww . j a v a 2 s .c o m*/
$x = 4;
$x = $x + 4; // $x now equals 8
print $x;
?>
The code above generates the following result.