if else condition

If else is a very important flow of any programming language. You use it very often in every small piece of every program that you write. Lot of large of chunks of code are executed based on a simple if else condition.

if else condition Tutorial

In this tutorial we will  write a if else condition in PHP to check the age of a user and display a message depending on the if else condition.

The code will display a message ‘you are an adult” if the age is greater than 18 or display a message ‘you are not an adult” if the age is less than 18.
1. Define a variable named age

2. Check if age is greater than 18, show a message “you are an adult”, otherwise show a message “you are not an adult”

Some uses and examples of if else condition

  • detect if a user is logged in
  • detect if the device if mobile or tablet or desktop
  • detect browsers and version