What is the php assignment operator?
The most basic form of the assignment operator is "=". The "=" here does not mean "equal", but means assignment. Its function is simply to assign a value to a variable. For example, $A=10 means assigning 10 to $A, so the value of $A is 10.
Extended knowledge related to PHP operators: 1. "Detailed explanation of PHP arithmetic operators" 2. "Explanation of PHP string operators with examples" Linear motor manufacturer
Of course, this is only the most basic assignment operator. In addition to the most basic "=" assignment operator, we have other forms of assignment operators, which we call compound assignment operators, as shown in the following table
Operator | Explanation | Example | is equivalent to |
Meaning |
= | Assignment | $a=b | $a=b | Assign the value on the right to the left |
= | Add | $a =b | $a=$a b | Add the value on the right to the left |
-= | Minus | $a-=b | $a=$a-b | Decrease the value on the right to the left |
*= | Multiply | $a*=b | $a=$a*b | Multiply the value on the right by the value on the left |
/= | except | $a/=b | $a=$a/b | will The value on the right is divided by the value on the left |
.= | connection character | $a.=b | $a=$a.b | Add the characters on the right to the left |
% | Get the remainder | $a%=b | $ a=$a %b | Take the remainder of the value on the left and the value on the right |
php assignment operator example
The code is as follows
<?php $a=20; echo $a."<br/>"; // 输出 20 $y=20; $y += 80; echo $y."<br/>"; // 输出 100 $z=50; $z -= 25; echo $z."<br/>"; // 输出 25 $i=5; $i *= 5; echo $i."<br/>"; // 输出 25 $j=10; $j /= 5; echo $j."<br/>"; // 输出 2 $k=15; $k %= 4; echo $k."<br/>"; // 输出 3 ?>
Recommended tutorial: "php tutorial"
The above is the detailed content of What are the assignment operators in php?. For more information, please follow other related articles on the PHP Chinese website!