Mastering the if-else Statement in PHP: A Complete Guide
☰Fullscreen
Table of Content:
You can enhance the decision making process by providing an alternative choice through adding an else statement to the if statement. The if...else statement allows you to execute one block of code if the specified condition is evaluates to true and another block of code if it is evaluates to false. It can be written, like this:
Syntax:
if(condition){ // Code to be executed if condition is true } else{ // Code to be executed if condition is false }
Example:
Output:
If you will rum the above code, you will get the following output.
Pay Amount : 2000 : Medical : 1500