Conditional Statement Syntax

If…Else
.if (condition){statements}
else if(condtion){statements}(0-infinity)
else(statements}{0-1}

Switch
.switch(variable)
{
case value: statements; break; (0-infinity)
default: statements; break; (0-1)
}

Loop Statements:
Loop statements are used to execute the code block several times.

While:
while(condtion){statements}
Do-while:
do {statements} while(condition)

For:
for(initialization; condition; increment){statements}

Foreach:
foreach(variable in array){statements}

There is two special statements there in loop statements:
break: end loop
continue: start next iteration (Send code execution to the beginning of the next iteration)

 

Advertisements

#conditional-statements