Else-If Statement
Syntax
Sample Program
Output
In the above program, if the First condition is false then it will check the third condition, if it’s true then print it else check next condition and so on.
Ternary or Conditional Operator.
It works similar to the else-if statement. In this Operator, if the condition is true then it returns First-Expression else Second-expression.
Syntax
Variable = Condition ? Expression1 : Expression2
For Example:- $a = (5>1) ? “Greater” : “Less” ;
Sample program
<?php
$a = (5>1) ? “Greater” : “Less” ;
echo $a;
?>
Output
Switch Statement
It checks several constant values for an expression.
Syntax
switch(expression){
case expression1:
block of statements;
break;
case expression2:
block of statements;
break;
case expression-n:
block of statements;
break;
default:
block of statements;
}
Sample Program
Output
- What is On-Page Optimization and Off-page Optimization - March 14, 2024
- [SOLVED] Flutter : PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 10: , null, null) - December 7, 2021
- [Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown - December 6, 2021