while Loop in PHP
Notes:
PHP while loop: Entry control loop
-PHP engine executes the statement(s) inside the while loop, until the given conditional expression evaluates to false.
Syntax:
initialization;
while(conditional expression)
{
statement(s);
increment/decrement;
}
OR
initialization;
while(conditional expression):
statement(s);
increment/decrement;
endwhile;
Ex:
$i=1;
while($i<=5)
{
echo("Hello World <br/>");
$i++;
}
OR
$i=1;
while($i<=5):
echo("Hello World <br/>");
$i++;
endwhile;
Note: When you don’t know exactly how many # of times the loop is going to get execute, use while loop.
Interview Questions:
1. PHP stands for ______________
a. Hypertext Preprocessor
b. Preprocessor Hypertext
c. Personal Home Processor
d. Personal Hypertext processor
Ans: a