-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch_case.php
61 lines (54 loc) · 1.69 KB
/
switch_case.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
//This is the if...elseif statement for a particular program
$page = "Signup";
if ($page == "Home") echo "You selected Home. <br>";
elseif ($page == "About") echo "You selected About. <br>";
elseif ($page == "News") echo "You selected News. <br>";
elseif ($page == "Login") echo "You selected Login. <br>";
elseif ($page == "Links") echo "You selected Links. <br>";
else echo "Page not Identified. <br>";
//If I am to use a switch case to reproduce the same program, It would look like this.
switch ($page)
{
case "Home":
echo "You selected Home. <br>";
break;
case "About":
echo "You selected About. <br>";
break;
case "News":
echo "You selected News. <br>";
break;
case "Login":
echo "You selected Login. <br>";
break;
case "Links":
echo "You selected Links. <br>";
break;
default:
echo "Page not Identified. <br>";
break;
}
//This is also another format under switch case to reproduce the same switch case program.
switch ($page) : //Here instead of the curly brackets {...}, we used :...endswitch;
case "Home":
echo "You selected Home. <br>";
break;
case "About":
echo "You selected About. <br>";
break;
case "News":
echo "You selected News. <br>";
break;
case "Login":
echo "You selected Login. <br>";
break;
case "Links":
echo "You selected Links. <br>";
break;
default:
echo "Page not Identified. <br>";
break;
endswitch;
//I've got to practice the switch case some more when I have time.
?>