The if / else Statement

In programming you use the if / else a lot

most of the programs are, if this is a fruite, then you can eat it, if it is not a fruit, then don't eat it

Or if the price is correct, show the picture, if not then go to another page, things like that

Let's see a little program with the if / else statement.

code in php

Yes, var is equal to 25

First you have a variable. $var = "25"

Then you have the "if" and the ( );

Inside the parenthesis you make your comparison, if "this" is "Fruit"

If "$var" is "25"

To do the comparison, we use the "==" double equal sign.

then inside the curly brackets { }

You echo, if it is fruit, or you write a code here to do something in the program

then the else { }, to write somthing if it is not true.

true is 1, and false is 0

A lot of times you will use, this if ( ) { } else { } Statement

As always, write a lot of code everyday, and read, study and learn.


Copyright 2017, July, 08