ホームページ > バックエンド開発 > PHPチュートリアル > PHP は switch ステートメントを使用して Web サイトのホームページをデザインします

PHP は switch ステートメントを使用して Web サイトのホームページをデザインします

巴扎黑
リリース: 2023-03-04 12:00:02
オリジナル
1970 人が閲覧しました

1つのPHPスクリプト

index.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

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>switch语句的应用</title>

<style type="text/css">

<!--

body {

background-color: #F1EFEB;

margin-left: 00px;

margin-top: 0px;

margin-right: 0px;

margin-bottom: 0px;

}

.STYLE4 {

color: #154049;

font-size: 13px;

}

a:link {

text-decoration: none;

color: #0A323C;

}

a:visited {

text-decoration: none;

color: #006600;

}

a:hover {

text-decoration: none;

color: #000033;

}

a:active {

text-decoration: none;

color: #003366;

}

-->

</style>

</head>

<body><center>

<table width="850" height="80" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td width="333" height="50"> </td>

    <td width="90"> </td>

    <td width="71"> </td>

    <td width="74"> </td>

    <td width="73" align="right"> </td>

    <td width="75" class="STYLE4">返回首页</td>

    <td width="83" class="STYLE4">加入收藏</td>

    <td width="51"> </td>

  </tr>

  <tr>

    <td height="30"> </td>

    <td align="center"> </td>

    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=最新商品"> 最新商品</a></span></td>

    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=热门商品"> 热门商品</a></span></td>

    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("推荐商品");?>">推荐商品</a></span></td>

    <td align="center"><span class="STYLE4"><a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>

    <td align="center"><span class="STYLE4"></span></td>

    <td> </td>

  </tr>

</table>

<table width="850" border="0" cellpadding="0" cellspacing="0">

  <tr>

    <td width="196" height="520" align="center" valign="top"><table width="180" height="523" border="1" cellpadding="1" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#F1F1F1">

      <tr>

        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">  <a href="index.php?lmbs=最新商品"> 最新商品</a></span></td>

      </tr>

      <tr>

        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">  <a href="index.php?lmbs=热门商品"> 热门商品</a></span></td>

      </tr>

      <tr>

        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">   <a href="index.php?lmbs=<?php echo urlencode("推荐商品");?>">推荐商品</a></span></td>

      </tr>

      <tr>

        <td height="25" align="center" bgcolor="#FFFFFF"><span class="STYLE4">   <a href="index.php?lmbs=<?php echo urlencode("特殊商品");?>">特殊商品</a></span></td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

      <tr>

        <td height="25" bgcolor="#FFFFFF"> </td>

      </tr>

    </table></td>

    <td width="600" align="center" valign="top"><table width="595" border="0" cellspacing="0" cellpadding="0">

      <tr>

        <td align="center" bgcolor="#FFFFFF">

<?php

switch($_GET[lmbs]){

case "最新商品":

        include "index1.php";

    break;

case "热门商品":

        include "index2.php";

    break;

case "推荐商品":

        include "index3.php";

    break;

case "特殊商品":

        include "index4.php";

    break;

case "":

        include "index4.php";

    break;

}

?></td>

      </tr>

    </table></td>

    <td width="54"> </td>

  </tr>

</table>

</center>

</body>

</html>

ログイン後にコピー

index1.php

1

2

3

4

5

6

7

8

9

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=gb2312">

<title>无标题文档</title>

</head>

<body>

<img  src="/static/imghw/default1.png"  data-src="images/bg6.jpg"  class="lazy"   style="max-width:90%" style="max-width:90%" alt="PHP は switch ステートメントを使用して Web サイトのホームページをデザインします" >

</body>

</html>

ログイン後にコピー

index2.php

1

2

3

4

5

6

7

8

9

10

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=gb2312">

<title>无标题文档</title>

</head>

<body>

<ahref="index.php?lmbs=新品上市"></a>

<img  src="/static/imghw/default1.png"  data-src="images/bg7.jpg"  class="lazy"   style="max-width:90%" style="max-width:90%" alt="PHP は switch ステートメントを使用して Web サイトのホームページをデザインします" >

</body>

</html>

ログイン後にコピー

index3.php

1

2

3

4

5

6

7

8

9

10

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=gb2312">

<title>无标题文档</title>

</head>

<body>

<a href="index.php?lmbs=<?php echo urlencode("特价区");?>"></a>

<img  src="/static/imghw/default1.png"  data-src="images/bg8.jpg"  class="lazy"   style="max-width:90%" style="max-width:90%" alt="PHP は switch ステートメントを使用して Web サイトのホームページをデザインします" >

</body>

</html>

ログイン後にコピー

index4.php

1

2

3

4

5

6

7

8

9

<html>

<head>

<metahttp-equiv="Content-Type"content="text/html; charset=gb2312">

<title>无标题文档</title>

</head>

<body>

<img  src="/static/imghw/default1.png"  data-src="images/bg7.JPG"  class="lazy"   style="max-width:90%" style="max-width:90%" alt="PHP は switch ステートメントを使用して Web サイトのホームページをデザインします" >

</body>

</html>

ログイン後にコピー

2回目の実行結果

PHP は switch ステートメントを使用して Web サイトのホームページをデザインします

3つの関数の説明

switch ステートメントを使用して Web サイトのホームページのレイアウトを設計し、Web サイトのヘッダー ファイルとテール ファイルを固定セクションとして設定し、ナビゲーション バーを固定セクションとして設定し、switch ステートメントを使用してさまざまな値を表示します。ハイパーリンクで渡された値に従って、異なるコンテンツ。


関連ラベル:
php
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
PHP 拡張子 intl
から 1970-01-01 08:00:00
0
0
0
phpのデータ取得?
から 1970-01-01 08:00:00
0
0
0
PHP GET エラー レポート
から 1970-01-01 08:00:00
0
0
0
phpを上手に学ぶ方法
から 1970-01-01 08:00:00
0
0
0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート