Assignment Operators in PHP
Assignment operators basically used to
assign one value in other variable or assign one variable value to other
variable.
|
Operator
|
Sign
|
Description
|
|
Addition
|
+
|
To make a sum of two or more than two values
Example :
<?php $a=10 ; $b=20 ; echo $a+$b ?> Output : 30
|
|
Subtraction
|
-
|
To find a difference between two or more than two
values.
Example :
<?php $a=10 ; $b=20 ; echo $b+$a ?> Output : 10
|
|
Multiplication
|
*
|
To perform a Multiplication between two or more
than two values
Example :
<?php $a=10 ; $b=20 ; echo $a*$b ?> Output : 200
|
|
Division
|
/
|
To perform division between two values where as
one value is Quotient and other value is divider of that Quotient values
Example :
<?php $a=10 ; $b=20 ; echo $b/$a ?> Output : 2
|
|
Modulus
|
%
|
To find the reminder after division operation, so
modules operation performs the divide operation internally and it shows the
reminder
Example :
<?php $a=10 ; $b=4 ; echo $a/$b ?> Output : 2
i.e.
10/4 Then 4*1=4, 4*2=8
So will keep 8 as its less than 10 and closer to 10 , then the reminder is 2 (
10-8 = 2)
|
Comments
Post a Comment