PHP-MySQLi Series 5.2 || Assignment operator
Assignment operators are used with numeric values to write a value to a variable.
We use symbol (=) to represent assignment operator.
Some practical example of assignment operator:
Assigning value directly:
Save this file as example.php
Here, the value of x is assign with number 10. And echo command is used to print data.
<?php
$x = 10;
echo $x;
?>
$x = 10;
echo $x;
?>
Assigning value after some operations:
Save this file as example.php
<?php
$x = 25;
$x = $x +10;
echo $x;
?>
$x = 25;
$x = $x +10;
echo $x;
?>
Or
<?php
$x = 25;
$x+= 10;
echo $x;
?>
$x = 25;
$x+= 10;
echo $x;
?>
No comments