if elseif else Statements in PHP

by Hiroshi on June 20, 2008

in Elseif, PHP Basics

To understand if, else if and else statements when we use these in the same script consider following example.

echo "Wrong";
echo "Wrong";
echo "Correct";

Output will be correct.
If apples are 3 then print wrong.
then if apples are 4 print wrong.
Otherwise print correct.
Variables apples has a value of 2. Not 3 or 4.
So the output is correct which is in else condition.

Related Posts

  • PHP If Statement To understand if statement consider the following script. The output will […]
  • PHP Else Statement To understand else statement consider following example. The output will […]
  • Elseif Conditions in PHP This example is based on if elseif and else. It is as simple as telling script to do […]
  • PHP While Loop The while keyword takes a condition in parentheses, and the code block that follows is […]
  • PHP Do While Loop A "do while" loop is a slightly modified version of the while loop. A do-while loop […]
  • PHP For Loop For loop consists of three phases. i.e. Define Condition Increment or […]
  • PHP Strings Before you can use a string you have to create it! A string can be used directly in a […]
  • Simple PHP Script – Lets Start PHP – Echo Hello PHP If you want to learn PHP you have come to the right place. I will not only teach you how […]
  • Data Types In PHP Data types are many e.g. Boolean, Integer, Double (or float), String and there might be […]
  • PHP – Implode The PHP function implode operates on an array and is known as the "undo" function of […]

Previous post:

Next post: