我一直在使用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