Youtube:
https://www.youtube.com/watch?v=EBrUfyRO3Y0&list=PLu0W_9lII9aikXkRE0WxDt1vozo3hnmtR&index=11
Blogpost:
https://www.codewithharry.com/videos/php-tutorials-in-hindi-10/
Case A
For example, we have two variables $a = 65; and $b = 9;
$a = 665;
$b = 9;
If($a > 78){
Echo "a is greater than 78";
}
Else{
Echo "a is not greater than 78";
}Case B$age = 24;
If ($age>18){
Echo "you can drink water with chai and alcohol";
}
Elseif($age>13){
Echo "you can drink chai only with water. No alcohol for you";
}
Else{
Echo "you can drink water only";
}
Case c:
If ($age>18){
echo "you can drink water with chai and alcohol<br>";
}
If($age>13){
echo "you can drink chai only with water. No alcohol for you<br>";
}
Else{
echo "you can drink water only<br>"
}
Code as described/written in the video
<?php
// $a = 665;
// $b = 9;
// if($a > 78){
// echo "a is greater than 78";
// }
// else{
// echo "a is not greater than 78";
// }
$age = 24;
// If else ladder
// if ($age>18){
// echo "You can drink water with chai and alcohol";
// }
// elseif($age>13){
// echo "You can drink chai only with water. No alcohol for you";
// }
// else{
// echo "You can drink water only";
// }
if ($age>18){
echo "You can drink water with chai and alcohol<br>";
}
if($age>13){
echo "You can drink chai only with water. No alcohol for you<br>";
}
else{
echo "You can drink water only<br>";
}
// Quick quiz -
// 1. Create an if else ladder using more than one elseif
// 2. Write a program to allow a driver to drive only when his age is greater than or equal to 25
// and less than or equal to 65
echo "Done";
?>
No comments:
Post a Comment