-
Notifications
You must be signed in to change notification settings - Fork 4
/
operators.php
88 lines (62 loc) · 1.66 KB
/
operators.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
/* Operators in PHP
1. Arithmetic Operators
2. Assignment Operators
3. Comparison Operators
4. Logical Operators
*/
$a = 45;
$b = 8;
// 1. Arithmetic Operators
echo "For a + b, the result is ". ($a + $b) . "<br>";
echo "For a - b, the result is ". ($a - $b) . "<br>";
echo "For a * b, the result is ". ($a * $b) . "<br>";
echo "For a / b, the result is ". ($a / $b) . "<br>";
echo "For a % b, the result is ". ($a % $b) . "<br>";
echo "For a ** b, the result is ". ($a ** $b) . "<br>";
// 2. Assignment Operators
// $x = $a;
// echo "For x, the value is ". $x . "<br>";
// $a += 6;
// echo "For a, the value is ". $a . "<br>";
// $a -= 6;
// echo "For a, the value is ". $a . "<br>";
// $a *= 6;
// echo "For a, the value is ". $a . "<br>";
// $a /= 5;
// echo "For a, the value is ". $a . "<br>";
// $a %= 5; // $a = $a % 5
// echo "For a, the value is ". $a . "<br>";
// 3. Comparison Operators
$x = 78;
$y = 78;
// echo "For x > y, the result is ";
// echo var_dump($x > $y);
// echo "For x > y, the result is ";
// echo var_dump($x >= $y);
// echo "For x < y, the result is ";
// echo var_dump($x < $y);
// echo "For x < y, the result is ";
// echo var_dump($x <= $y);
echo "For x <> y, the result is ";
echo var_dump($x <> $y);
echo "<br>";
// 4. Logical Operators
$m = true;
$n = true;
echo "For m and n, the result is ";
echo var_dump($m and $n);
echo "<br>";
echo "For m && n, the result is ";
echo var_dump($m && $n);
echo "<br>";
echo "For m or n, the result is ";
echo var_dump($m or $n);
echo "<br>";
echo "For m || n, the result is ";
echo var_dump($m || $n);
echo "<br>";
echo "For !m , the result is ";
echo var_dump(!$m);
echo "<br>";
?>