Turn Your Vehicle Into a Smart Earning Asset

While you’re not driving your car or bike, it can still be working for you. MOTOSHARE helps you earn passive income by connecting your vehicle with trusted renters in your city.

πŸš— You set the rental price
πŸ” Secure bookings with verified renters
πŸ“ Track your vehicle with GPS integration
πŸ’° Start earning within 48 hours

Join as a Partner Today

It’s simple, safe, and rewarding. Your vehicle. Your rules. Your earnings.

What are If, Nested if, if else and, Nested if else Statement in PHP?

If Statement and Nested if Statement

If statement is used to execute when a statement or a block of statement only if the condition is fulfilled or true.

Syntax

For One Statement:-

if(condition/expression)
statement;

For more than one Statement:-

if(condition/expression)
{
Blocks of statement;
}

OR

if(condition/statement):
Blocks of statements;
endif;

Sample Program

Output

Nested if Statement

We can make nesting statement by nesting the if statement. It means when we insert a second if statement inside an if statement, we call it nested if statement or nesting the if statement.

Sample Program

Output

To know more about If Statement and Nested if Statement Click here – If Statement and Nested if Statement

if else and Nested if else Statement.

A statement executes code if if_condition is true and executes another code if if_condition is false.

Syntax

if(condition/expression)
{
Statement1;
}
else echo “Statement2”;

Example – when Condition is True then, if_condition executes. See Below

Sample Program

Output

when Condition is False then, else_condition executes. See Below

Sample Program

Output

Nested if else Statement

we insert a second if_else statement inside an if_else statement, we call it nested _if_else statement.

syntax

if(condition/expression)
{
if(condition/expression)
{
Statement1;
}
else echo “Statement2”;
}
else echo “Statement2”;

Sample Program

In the above program, The first Condition is true, then it enters in 2nd condition to check and when the 2nd condition is true then it prints that statement and skips other else statements. See the Output below:

Click Here For Next Part – Difference between Single Equal, Double Equal and, Triple Equal in PHP

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.