You are on page 1of 6

1.!

DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
if (condition) {

} elseif (condition) {

} else {

}
?>
</body>
</html>

2.<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
switch (2) {
case 0:
echo 'The value is 0';
break;
case 1:

echo 'The value is 1';


break;
case 2:
echo 'The value is 2';
break;
default:
echo "The value isn't 0, 1 or 2";
}
?>
</body>
</html>

3.<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$myNum = 2;

switch ($myNum) {
case 1:
echo "1";
break;
case 2:
echo "2";
break;
case 3:
echo "3";
break;

default:
echo "None of the above";
}

?>
</body>
</html>

4.-

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$i = 5;

switch ($i) {
case 0:
echo '$i is 0.';
break;
case 1:
case 2:
case 3:
case 4:
case 5:
echo '$i is somewhere between 1 and 5.';
break;
case 6:

case 7:
echo '$i is either 6 or 7.';
break;
default:
echo "I don't know how much \$i is.";
}
?>
</body>
</html>

5.-

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$i = 5;

switch ($i):
case 0:
echo '$i is 0.';
break;
case 1:
case 2:
case 3:
case 4:
case 5:

echo '$i is somewhere between 1 and 5.';


break;
case 6:
case 7:
echo '$i is either 6 or 7.';
break;
default:
echo "I don't know how much \$i is.";
endswitch;
?>
</body>
</html>

6.-

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
switch (X) {
case X:

break;

default:
case XX:

break;
case XXX:
break;
}

?>
</body>
</html>

You might also like