php2
php2
1. Conditional statements
1.1. if statement
a.
if (condition)
{instruction;}
b.
if (condition)
{ instructions1; }
else
{instructions2;}
c.
if (condition1)
{ instructions1; }
else if (condition2)
{ instructions2 ;}
switch ( expression )
{
case value1 : { instructions1 ; break ;}
case value2 : { instructions2 ; break ;}
….
default : { instructionsN ;}
}
2. Looping statements
2.1. while statement
while (condition)
{
instructions;
}
do
{
instructions;
} while (condition) ;
<?php
$a=1;
do {
echo $a.' ';
$a++;
} while ($a<=5);
?>
12345
Example
<?php
for($i=0;$i<50;$i++)
{
echo $i.'<br>';
}
?>