“IF” is a conditional statement that gives the opportunity to choose between two values. It can also be used to validate the program. Login applications are good example of if else statement.
Apart from PHP there are many more programming languages that too uses if else statement as a conditional operator.
Lets take an example to understand it in better way... suppose we have only one item in the database and if the user chooses the same item he can shop else a message will given to user that “there is no such item available”.Code:
echo "You can buy!";
echo "There is no such item available.";
This was just a simple example that has used if statement only one time in the whole code. But there could be situation like you wanted to use it more then once. PHP also support this feature, you can use if statement in your program as many times as you want.Syntax of PHP if else if Statement
Execute if condition is true;
Executed if second condition is true;
In case both conditions are false;
Recommend the tutorial