If else in PHP
There exist some conditions in “If Else Statements” to perform some specific tasks. All actions/functions totally depend on the conditions specified in “If Else Statement”. The condition can be True or False. Example of If Else Statement For example, in the figure, we can see the following real-life examples;- If we obey God, We will get Heaven, Otherwise/Else we will get Hell.
- If someone fails in the exams, he will weep, Otherwise/Else he will be happy with a smile.
- If you work smart and work hard, you will get more money, Otherwise/Else you will get less money.

1 2 3 4 5 6 7 8 9 10 11 |
<?php $number=5; if($number % 2 == 0) { echo "number is even"; } else { echo "number is odd"; } ?> |