What is the PHP assignment operator?
The most basic form of the assignment operator is "=", where the "=" is not "equal to", is the meaning of the assignment, it is the function of the simple point is to assign value to the variable, for example, $a=10, meaning to give 10 $ A, so that the value of $ A is 10.
PHP operators related to extension knowledge: 1. " The PHP arithmetic operator is detailed in "2." An example of a PHP string operator explains "
This is, of course, just the most basic assignment operator. In addition to the most basic "=" assignment operators, we have other forms of assignment operators, which we call compound assignment operators, as shown in the following table
Operator |
Description |
Example |
Equivalent to |
Significance |
= |
Assign value |
$a =b |
$a =b |
Assign the value on the right to the left |
+= |
Add |
$a +=b |
$a = $a +b |
Add the right value to the left |
-= |
Reducing |
$a-=b |
$a = $a-b |
Reduce the value on the right to the left |
*= |
By |
$a *=b |
$a = $a *b |
Multiply the value on the right by the left |
/= |
Except |
$a/=b |
$a = $a/b |
Divide the value on the right by the left |
.= |
Connection character |
$a. =b |
$a = $a. b |
Multibyte the right word to the left |
% |
Take the remainder |
$a%=b |
$a = $a +%b |
Take the left side of the value to the right of the remainder |
PHP Assignment Operator Instance
The code is as follows
<?php$a=20;echo $a. " <br/> "; Output 20$y=20; $y + = 80;echo $y. " <br/> "; Output 100$z=50; $z-= 25;echo $z. " <br/> "; Output 25$i=5; $i *= 5;echo $i. " <br/> "; Output 25$j=10; $j/= 5;echo $j. " <br/> "; Output 2$k=15; $k%= 4;echo $k. " <br/> "; Output 3?>
Operation Result: