Assignment Operators in PHP

Estudies4you
Assignment Operators in PHP
Assignment Operators
The table below lists assignment operators along with description and examples.


Example:
Script: Assign_op.php
<html>
<head>
<title>Assignment Operators</title> </head>
<body>
<?php
$a = 32;
$b = 15;
echo "a=".$a."</br>";
echo "b=".$b."</br>";
$c = $a + $b; /* Assignment operator *
echo "Addition Operation Result: $c <br/>";
$c += $a;
echo "Add AND Assignment Operation Result: $c <br/>";
$c -= $a;
echo "Subtract AND Assignment Operation Result:
$c <br/>";
$c *= $a;
echo "Multiply AND Assignment Operation Result: $c <br/>";
 $c /= $a;
echo "Division AND Assignment Operation Result: $c <br/>";
$c %= $a;
echo "Modulus AND Assignment Operation Result: $c <br/>";
?>
</body>
</html>

OUTPUT:
a=32
b=15;
Addition Operation Result:47
Add AND Assignment Operation Result:79
Subtract AND Assignment Operation Result:47
Multiply AND Assignment Operation Result:1504
Division AND Assignment Operation Result:15


To Top