For use the PHP control structures. You need to know about the operators using in control structures.

Comparison Operators

Operator

Description

Example

==

is equal to

5==8 returns false

!=

is not equal

5!=8 returns true

>

is greater than

5>8 returns false

<

is less than

5<8 returns true

>=

is greater than or equal to

5>=8 returns false

<=

is less than or equal to

5<=8 returns true

Logical Operators

Operator

Description

Example

&&, and

and

x=6
y=3

(x < 10 && y > 1) returns true

||, or

or

x=6
y=3

(x==5 || y==5) returns false

!

not

x=6
y=3

!(x==y) returns true

• if, else, ifelse

The if statement evaluates the truth value of it's argument. If the argument evaluate as TRUE the code following the if statement will be executed. And if the argument evaluate as FALSE and there is an else statement then the code following the else statement will be executed.

syntax :

if(condition){ codes and commands when evaluate is true.
}

if(condition){ codes and commands when evaluate is true.
}else{ codes and commands when evaluate is false.
}

if(condition1){ codes and commands when evaluate is true.
}elseif(condition2){ codes and commands when evaluate is true.
}else{ codes and commands when all evaluate is false.
}

• while

The while statement is used to execute a piece of code repeatedly as long as the while expresssion evaluates as true.

syntax :

while(condition){ codes and commands while evaluate is true.
}

That loop will continue to run forever as long as the loop expression ($number < 10) evaluates as true. When you are creating a loop please make sure you already put the code to make sure the loop will end in timely manner.

Break

The break statement is used to stop the execution of a loop. As an example the while loop below will stop when $number equals to 5.

• for

syntax :

for(define parameter ; condition ; add or decrease parameter){ codes and commands while evaluate is true.
}