Decision making statments are used to take decision, which code is to be executed, based on the specified condition. Decision making statements are also known as conditional statements. PHP supports following types decision making statements:
Example 1: If condition.
<html> <body> <?php $d=date("D"); if ($d=="Sun") echo "Happy Sunday!"; ?> </body> </html>
Example 2: Fetch current day and check it is sunday or not using if...else
<html> <body> <?php $d=date("D"); if ($d=="Sun") // for one line statement curly bracket is optional echo "Happy Sunday!"; else echo "Its a working day"; ?> </body> </html>
Example 3: Fetch current day and check it is sunday, saturday or any other day using if...else if statement
<html> <body> <?php $d=date("D"); if ($d=="Sun") echo "Happy Sunday!"; else { //curly brackets define the block if($d=="Sat") echo "Its a Half day"; else echo "Working Day" } ?> </body> </html>