Php Tutorials: Basics 4 – Conditional Statements if else, if elseif else & switch

Welcome to easy online jobs’ video tutorials.

In this video, we learn Conditional Statements in PHP.

Conditional statements are used to perform different actions based on different conditions.

In PHP we have the following conditional statements:

if statement – use this statement to execute some code only if a specified condition is true.

if else statement – use this statement to execute some code if a condition is true and another code if the condition is false.

if elseif else statement – use this statement to select one of several blocks of code to be executed.

switch statement – use this statement to select one of many blocks of code to be executed.

First we’ll learn The if Statement.
Use the if statement to execute some code only if a specified condition is true.
Check the syntax of if Statement here.

Now we will see the output of our php code in wamp server.

Now we’ll learn The if else Statement.
Use the if else statement to execute some code if a condition is true and another code if a condition is false.
Check the syntax of if else Statement here.

Now we will see the output of our php code in wamp server.

Now we’ll learn The if elseif else Statement.
Use the if elseif else statement to select one of several blocks of code to be executed.
Check the syntax of if elseif else Statement here.

Now we will see the output of our php code in wamp server.

Now we’ll learn The PHP Switch Statement.
Use the switch statement to select one of many blocks of code to be executed.
Check the syntax of PHP Switch Statement here.

Now we will see the output of our php code in wamp server.

Thanks for watching this video. Please wait for more tutorials.

source