If-Else If Condition Statement in PHP

If-else if condition statement in Php. A Php program to execute the if-else if condition. Using this simple PHP program we can print the if-else condition in PHP. The conditional statements in PHP are as follows: If a condition is true, the if statement executes some code. If a condition is true, the if-else statement executes some code; if the condition is false, it executes another code. If more than two conditions are met, the else if and else statements are used to execute different programs.

$t = date("H");
if ($t < "1")
echo "You can learn programming";
elseif ($t < "2")
echo "Good for php";
else {
echo "Welcome to php";



Welcome to php

If Else Statement in PHP

The if-else statement is executed regardless of whether the condition is true or false. The if-else statement differs from the if statement in a few ways. If the specified condition is true, one block of code is executed; if the condition is false, another block of code is executed. 

The if/else if statement can be used to create a chain of if statements. The if statements are evaluated in order until one of the if expressions is true or the if/else if chain is complete. No code blocks are executed if there is no true expression at the end of the if/else if chain.

Otherwise known as elseif, else if is a conditional statement that is executed after an if statement and performs a function if true.

date() Function in PHP

The date() function in PHP is used to format the date and time. A timestamp can also be formatted with the date() function. A timestamp is a string of characters that represents the date and/or time when an event occurred.