Conditional statements are used to perform different actions based on different conditions.
// using if...else statement php
$age = 18;
if($age >= 18) {
echo "She can vote in election";
}else {
echo "She is not eligible for voting";
}
// using if...elseif...esle statement php
$marks = 68;
if($marks >= 65) {
echo "First Division";
}else if($marks >=55 && $marks <= 64) {
echo "Second Division";
}else if($marks >= 45 && $marks <= 54) {
echo "Third Division";
}else {
echo "Failed";
}
0 comments
Post a Comment