PHP Assignment Operators

In this chapter you will learn:

  1. What is assignment operator
  2. 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/*  j a va2  s .c o m*/
$x = 4;
$x = $x + 4; // $x now equals 8

print $x;
?>

The code above generates the following result.

Next chapter...

What you will learn in the next chapter:

  1. What are arithmetic operators
  2. PHP Arithmetic Operators
Home » PHP Tutorial » PHP Operators
PHP Assignment Operators
PHP Arithmetic Operators
PHP Incrementing and Decrementing Operators
PHP Comparison Operators
PHP Logical Operators
PHP String Operators
PHP Ternary Operator
PHP Bitwise Operators
PHP Execution Operator
PHP Operator Precedence