Forth Day
1. Arithmetic operator :
Operator
|
Description
|
Example
|
+
|
Adds two
operands
|
A+B will give
30
|
-
|
Subtracts
second operand from the first
|
A-B will give
-10
|
*
|
Multiply both
operands
|
A*B will give
200
|
/
|
Divide
numerator by denumerator
|
B/A will give
2
|
%
|
Modulus
Operator and remainder of after an integer division
|
B%A will give
0
|
अंक गरितिय कम गर्न Arithmetic operator को प्रयोग गरिन्छ +,-,*,/,%
Example:
<!DOCTYPE html>
<html>
<head>
<title>php operator</title>
</head>
<body>
<?php
$a=20;
$b=5;
$sum=$a+$b;
$sub=$a-$b;
$mul=$a*$b;
$div=$a/$b;
$rem=$a%$b;
echo "$sum";
echo "<br>".$sub;
echo "<br>".$mul;
echo "<br>".$div;
echo "<br>".$rem;
?>
</body>
</html>
2. Increment/Decrements operator:
++
|
Increment
operator, increases integer value by one
|
A++ will give
11
|
--
|
Decrement
operator, decrease integer value by one
|
A-- will give
9
|
Note:
कुनै पनि value को अगाडी ++ छ à¤à¤¨े सुरुमै +1 ले increse गरी operation गर्छ र result दिन्छ [preincrement]
कुनै पनि value को अगाडी -- छ à¤à¤¨े सुरुमै -1 ले decrease गरी operation गर्छ र result दिन्छ [predecrement]
कुनै पनि value को पगाडी ++ छ à¤à¤¨े operation गर्छ र पछि +1 ले increse गरी result दिन्छ [postincrement]
कुनै पनि value को पगाडी -- छ à¤à¤¨े operation गर्छ र पछि पछि-1 ले decrease गरी result दिन्छ [postdecrement]
Example:
<!DOCTYPE html>
<html>
<head>
<title>increment and decrement operator</title>
</head>
<body>
<?php
$a=20;
++$a;
echo $a;
--$a;
echo "<br>".$a;
$b=21;
$c=--$a+$b--;
echo "<br>".$c;
echo "<br>$b";
?>
</body>
</html>