Skip to main content

//Assignment Operators

Assignment Operators

  1.  <?php 

  2. $a = 21; 
  3. $c = 10;  // $ use for variables 

  4. //Add AND
  5. $c += $a; //c = c + a; 10 + 21 = 31;
  6. echo ("the value of c is :".$c."<br>"); // <br> use for linebreake

  7. //Subtract AND
  8. $c -= $a; //c = c - a; 31 - 21 = 10;
  9. echo ("the value of c is :" .$c."<br>"); // .$c. is used to indicate which value should be print.

  10. //Multiply AND
  11. $c *= $a; //c = c * a; 10 * 21 = 210;
  12. echo ("the value of c is :" .$c."<br>"); // echo use for print line.

  13. //Divison AND
  14. $c /= $a; // c = c /a; 210/10 = 10;
  15. echo ("the value of c is :". $c."<br>");

  16. //Mod AND
  17. $c %= $a; // c = c % a; 10 % 10 =10;
  18. echo ("the value of c is :" .$c."<br>");
  19.  ?>

//Execute

//Output

/* 

the value of c is :31

the value of c is :10

the value of c is :210

the value of c is :10

the value of c is :10 

*/


                                                                       //ThE ProFessoR