Assignment Operators
- <?php
- $a = 21;
- $c = 10; // $ use for variables
- //Add AND
- $c += $a; //c = c + a; 10 + 21 = 31;
- echo ("the value of c is :".$c."<br>"); // <br> use for linebreake
- //Subtract AND
- $c -= $a; //c = c - a; 31 - 21 = 10;
- echo ("the value of c is :" .$c."<br>"); // .$c. is used to indicate which value should be print.
- //Multiply AND
- $c *= $a; //c = c * a; 10 * 21 = 210;
- echo ("the value of c is :" .$c."<br>"); // echo use for print line.
- //Divison AND
- $c /= $a; // c = c /a; 210/10 = 10;
- echo ("the value of c is :". $c."<br>");
- //Mod AND
- $c %= $a; // c = c % a; 10 % 10 =10;
- echo ("the value of c is :" .$c."<br>");
- ?>
//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