38. L?p tr足nh v角 Thi?t k? Web 1 每 B角i 7 : PHP C? b?n
? 2007 Khoa CNTT - ?HKHTN
?i?u ki?n if
if (condition)
{
statement[s] if true
}
else (condition)
{
statement[s] if false
}
V赤 d?:
$x = 5;
if ($x < 4)
echo ※$x is less than 4§;
else
print ?$x isn?t less than 4?;
$x isn*t less than 4
39. L?p tr足nh v角 Thi?t k? Web 1 每 B角i 7 : PHP C? b?n
? 2007 Khoa CNTT - ?HKHTN
?i?u khi?n switch
switch (expression)
{
case label :
statementlist
break;
case label :
statementlist
break;
...
default :
statementlist
}
V赤 d?:
$menu = 3;
switch ($menu){
case 1:
echo "You picked one";
break;
case 2:
echo "You picked two";
break;
case 3:
echo "You picked three";
case 4:
echo "You picked four";
break;
default:
echo "You picked another option";
}
You picked three You picked four