What is php assignment operator?

What is php assignment operator?

 

The most basic form of the assignment operator is "=", where "=" not "means equal to" is meant assignment, which role is to say a simple dot variable value, for example $ A = 10, meaning that the 10 value given $ a, so $ a is 10.
php operator knowledge related extension:. 1 "php Detailed arithmetic operators" 2. "String operators php examples to explain the" linear motor manufacturer

Of course, this is only the most basic assignment operator. In addition to the basic "=" assignment operator, we have other forms of assignment operators, assignment operators we call complex, as shown below

Operators Explanation For example Equivalent to significance
= Assignment $a=b $a=b The value assigned to the right of the left
+= plus $a+=b $a=$a+b The value added to the right of the left
-= Less $a-=b $a=$a-b Reduced the value of the right to the left
*= Multiply $a*=b $a=$a*b Multiplied by the value of the right to the left
/= except $a/=b $a=$a/b Divided by the value of the right to the left
.= Character connection $a.=b $a=$a.b The character is added to the right of the left
% Take the remainder $a%=b $a=$a+%b The value of the left side to the right side take the remainder

Examples of the assignment operator php

code show as below

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

<?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

?>

Guess you like

Origin www.cnblogs.com/furuihua/p/12111521.html