我一直在使用PHP構建網站。我對使頁面正確顯示的方法或技巧感到困惑。使用.html和.php對頁眉和頁腳進行說明
我的主要入門點是index.html
。從這裏,用戶可以點擊瀏覽。我希望所有12個頁面具有相同的標題信息。 我試過在Dreamweaver中使用標籤,然後只是標籤。
??我感到困惑的使用標籤和使用 文件之間的差異被稱爲header.php
跟進:要建議的對策。我編輯代碼建議
現在,當我'在瀏覽器中查看'我得到'服務器未找到'。
注意。我使用DreamweaverCC:
文檔根目錄/庫/ Web服務器/文件
的header.php:
<!doctype html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<h1>General Header Information for Top of Each Page</h1>
的index.html
<?php include_once ('header2.php'); ?>
<!doctype html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>index.php</title>
<link href="file:////Library/WebServer/Documents/webDevelopDWsites /boilerplate.css" rel="stylesheet" type="text/css">
<link href="file:///Library/WebServer/Documents/webDevelopDWsites/indexFourSquare.css" rel="stylesheet" type="text/css">
<script src="file:///Library/WebServer/Documents/webDevelopDWsites/respond.min.js"> </script>
</head>
<body>
<?php include 'header2.php'; ?>
<div class="gridContainer clearfix">
<div id="div1" class="fluid">
<header id="header" class="fluid">Web Development by myName</header>
<div id="Square1" class="fluid"><a href="file:///Library/WebServer/Documents /webDevelopDWsitesimages/Square1.jpg"><img src="images/Square1.jpg" alt=""/></a></div>
<div id="Square2" class="fluid"><a href="file:///Library/WebServer/Documents/webDevelopDWsites/Square2.html"><img src="images/Square2.jpg" alt=""/></a></div>
<div id="Square3" class="fluid"><a href="file:///Library/WebServer/Documents/webDevelopDWsites/Square3.html"><img src="images/Square3.jpg" alt=""/></a></div>
<div id="Square4" class="fluid"><a href="file:///Library/WebServer/Documents/webDevelopDWsites/Square4.html"><img src="images/Square4.jpg" alt=""/></a></div>
<div id="siteMap" class="fluid">siteMap</div>
</div>
</div>
</body>
</html>
我是否包括header.php
在每個其他網頁的代碼中?我做了這個,但沒有奏效。
所以我試過這個:我創建了一個index.php
並將所有的index.html
代碼複製到index.php
中,並且在代碼的頂部添加了這個代碼。
<?php include 'header.php'; ?>
當我使用 '在瀏覽器中查看' 啓動index.html
: '無頭信息'
- 我得到的網頁正確
- 但
當我在圖像上點擊瀏覽到其他頁面,它的工作原理:
- 但「沒有頭信息」。
當我點擊index.php
:
- 我只得到了標題信息。
默認情況下,您必須爲您的擴展名指定「.php」。否則,你的php代碼將不會被解釋。 – OpenStark
@iHaveAQuestion編輯中的禁用術語是什麼?我改變了標題,以便您的問題更容易找到,並且您可能會得到更多答案。 –
@icanhascheezburger進展。 '無法連接'文檔根目錄庫/ Web服務器/文檔。我創建了一個新文件夾:Library/WebServer/Documents/dwwdSite(= DreamWeaverWebDevelopmentSite)。但是當我輸入URL localhost/dwwdSite/error:'無法連接'。 dwwdSite的網站設置:name = localhost。地址= macHD/library/WebServer/Documents。連接=本地/網絡。測試檢查。本地信息網址:Http:// localhost /。網站名稱= dwwdSite。本地站點文件夾=/Library/WebServer/Documents/dwwdSite。我覺得在這些設置中我必須有不正確的東西。仍然'無法連接'。 – iHaveAQuestion