PHP Conditional Logical Operator and Usage Part-2

In part 1 we have discussed about logic and var_dump() function. In this part we will discuss about usage of var_dump() function, if, else, else if and examples.

We have used $personOne and $personTwo in last part 1 where we used 35 for $personOne and 40 for $personTwo. Let’s compare and find out the boolean output from var_dump(). 

Output:

 

We used greater(>) sign, so var_dump() will give false. Because $personOne is not bigger than $personTwo. But if we use less(<) than sign then var_dump() give true.

Now condition is true. For this reason var_dump() returns true. You can check any kind of variable type or condition using this simple  var_dump() function.

Let’s see some real life example of if, else and elseif

Example 1 For IF Condition

Output:

Example 2 For IF Condition

Output:

 

 

Example of if else Condition

Example of  else if Condition

Output

Hope that you have got a better ideas about conditional logic. This page will be modified also in future with several examples and explanation.

Share This on Social Media