Use assignment operator in PHP

Description

The following code shows how to use assignment operator.

Example


<?php//w  w  w.j a  va 2s  . c  om
  //Add 5 to Count
  $Count = 0;
  $Count = $Count + 5;

  //Add 5 to Count
  $Count = 0;
  $Count += 5;

  //prints 13
  print($a = $b = 13);
  print("<br>\n");

  //prints 7
  $Count = 2;
  print($Count += 5);
  print("<br>\n");
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Language Basic »




PHP Introduction
PHP Operators
PHP Statements
Variable
PHP Function Create
Exception
PHP Class Definition