The assignment operators are to assign values to variables. The basic assignment operator is “=” sign, which can be used alone or in combination with arithmetic operators as shown in the example.
Example of assignment operators
<?php
$a = 3; // assigns value of 3 to variable $a
$a = ($b = 4) + 5; //$a equals to 9 while $b is set to 4
$b = "Robert"; // A string is assigned to variable $b
$a += 5; // this is the same as $a = $a + 5;
$b = &$a; // $b is a reference to $a
$a -= $b; // this is the same as $a = $a - $b
$a *= $b; // this is the same as $a = $a * $b
$a /= $b; // this is the same as $a = $a / $b
$a %= $b; // $a is modulus of $b
?>
Comments
No comments have been made yet.
Please login to leave a comment. Login now