এই lesson আমরা PHP এর Variable, String, Constant, Array, Operators, For loop, While Loop, Do While Loop, For Each Loop নিয়ে আলোচনা করবো
Array:
$a = [1, 2, 5, 3, 9];
$b = [
'b' => 78,
'g' => 21,
'k' => 57
];
$c = [
[1, 2, 3],
[4, 5, 6]
];
asort($b);
print_r($b);
Conditional Statement IF:
$a = 12;
if ($a == 6) {
echo "Welcome";
} else if ($a == 5) {
echo "Welcome to dhaka";
} else {
echo 'Go home';
}
Switch Statement:
$a = 12;
switch ($a) {
case 6:
echo "Welcome";
break;
case 5:
echo "Welcome to dhaka";
break;
default:
echo "Go home";
break;
}
Loop:
for( $i = 1; $i <10; $i++ ) {
echo "$i ";
}
echo "
";
$j = 1;
while($j < 10) {
echo "$j ";
$j++;
}
echo "
";
$k = 1;
do {
echo "$k ";
$k++;
} while( $k < 10 );
Foreach loop:
items = [ 2, 45, 12, 23, 12, 40 ];
foreach($items as $key => $item) {
echo "($key, $item) ";
}