-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.php
More file actions
135 lines (111 loc) · 2.85 KB
/
Example.php
File metadata and controls
135 lines (111 loc) · 2.85 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
// $fname = "Hossen";
// $lname = "Tamzid";
// printf("His name is %s is %s", $fname, $lname); //His name is Hossen is Tamzid
// echo "\n";
// printf('His name is %2$s is %1$s', $fname, $lname); //His name is Tamzid is Hossen
// echo "\n";
// printf('The binary equivalent of %1$d is %1$b', 13); //The binary equivalent of 13 is 1101
// echo "\n";
/* $n = 34.234;
printf("%.2f", $n); //34.23
echo "\n";
$m = 1234.2345; //01234.23
$k = 23.155; //00023.16
printf("%08.2f\n", $m);
printf("%08.2f\n", $k); */
/* Day 2*/
// $fname = "Isaac";
// $lname = "Newton";
// $n = 12;
// $tmp = sprintf("His name is %s %s", $fname, $lname);
// echo $tmp;
// echo "\n";
// if($n % 2 == 0){
// echo "$n is a Even Number";
// }else {
// echo "$n is a Odd Number";
// }
/* Day 3 */
/*$n = 15;
// $numberInword = $n == 14 ? "Twelve" : "Invaled Number";
$numberInword = ($n == 12) ? "Twelve" : (($n >= 12) ? "OK": "False");
echo $numberInword;
echo PHP_EOL;*/
/** Day 4 */
// $fname = "Isaac";
// $lname = "newTon";
// $outPut = sprintf("His name is %s %s", $fname, $lname);
// echo $outPut;
// $color = 'red';
// switch($color){
// case 'red':
// case 'green':
// echo /** ucwords hocce 1st letter big kore Exm: Red, Green */ ucwords($color). " is our favorite color";
// break;
// case 'Blue':
// echo "Blue is our favorite color";
// break;
// default:
// echo "This color is True";
// }
// $a = true && false; //false
// $b = true and false; //true
// var_dump($a, $b); /** Opertator Precedence */
// for($i=1; $i<10; $i++){
// // echo "*". PHP_EOL;
// echo PHP_EOL;
// for($j=0; $j<$i; $j++){
// echo $j. " ";
// }
// }
// for($i=10, $j=1; $i>0; $i--, $j++){
// echo $i. ":". $j;
// echo PHP_EOL;
// }
// $i=0;
// while(++$i<5){
// echo $i. PHP_EOL;
// // ++$i;
// }
// for($i=0; $i<10; $i++){
// if($i>=5){
// continue;
// }
// echo $i. PHP_EOL; /**0 1 2 3 4 */
// }
// for($i=0; $i<50; $i++){
// echo ($i==100) ? $i. PHP_EOL:"";
// }
//include_once "function.php"; /**Reference Function.php */
//$cnt = 04;
// if(evenOrOdd($cnt)){ /**argument */
// echo "{$cnt} is an even number";
// } else {
// echo "{$cnt} is an odd number";
// }
// echo PHP_EOL;
//echo "Factorial of {$cnt} is ".factorial($cnt);
function src(int ...$number):int {
$result = 0;
for($i=0; $i<count($number); $i++){
$result += $number[$i];
}
return $result;
}
//echo src(1,2,3,4); /**Ans:: 10 */
$students = [
"anik",
"zamal",
"zafor",
"korim"
];
array_push($students, "azom"); //insert item in last
array_pop($students); //delete in last item
array_shift($students); //delete in fast item
array_unshift($students, "salma"); //insert item in top
$cnt = count($students);
echo $cnt."\n";
for($i=0; $i<$cnt; $i++){
echo $students[$i].PHP_EOL;
}