Php 在html设计中插入页面

Php 在html设计中插入页面,php,jquery,html,css,Php,Jquery,Html,Css,我已经设计了一个网站,有20页,菜单和标题有css设计我的问题是,如果我改变菜单内容,那么我必须改变所有的页面,所以如何使标题单独的页面 我已经尝试并包括页面方法,但没有工作请 代码段: <!DOCTYPE html> <html class=" no-bgpositionxy" xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta http-

我已经设计了一个网站,有20页,菜单和标题有css设计我的问题是,如果我改变菜单内容,那么我必须改变所有的页面,所以如何使标题单独的页面

我已经尝试并包括页面方法,但没有工作请

代码段:

     <!DOCTYPE html>
     <html class=" no-bgpositionxy" xmlns="http://www.w3.org/1999/xhtml" lang="en">
        <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
           <title>sample</title>
        <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
    <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
    <script type="text/javascript" src="js/custom.js"></script>
    <link rel="stylesheet" href="css/nivo-slider.css" type="text/css"    media="screen" />
    <script src="js/jquery.nivo.slider.js" type="text/javascript"></script>



    <link rel="shortcut icon" href="Fav.ico">
   <meta name="robots" content="follow,index">



    <link type="text/css" href="css/BodyAlign.css" rel="stylesheet" media="all">



     <script type="text/javascript" src="js/Menu.js"></script>
     <script type="text/javascript" src="js/Menu1.js"></script>

    <script type="text/javascript" src="js/MenuDrop.js" language="javascript"></script>
   <script type="text/javascript" language="javascript">
            ct = "us";
            selURL = "manufacturing.html";
            $(function(){$('#popularSearches,#country-list').hide();});
        </script>


    <style media="screen" type="text/css">
     <!--
      .enlarge {width:330px;bottom:55px;}

      --> 
     </style>


  </head>

 <!-- Head -->

  <body>

样品
ct=“美国”;
selURL=“manufacturing.html”;
$(function(){$('#popularSearchs,#country list').hide();});
下面的代码是菜单,所以我想为下面的代码做单独的页面

<header id="header"> <div class="container">   <div id="topnav_wrap"> <ul id="topnav"> <li class="topnav_column_title"> <a href="index.html">Home</a></li>

  <li id="why_workday_menu"> <a href="manufacturing.html">Why </a> <div style="width: 200px;" class="topnav_content 1-columns"> <ul class="topnav_column1 last">

<li class="topnav_column_title"> <a href="manufacturing.html">Why </a></li> <li> <a href="manufacturing.html">Designed for the Way You Work</a></li> <li> <a href="manufacturing.html">Real Cloud</a></li> <li> <a href="manufacturing.html">Mobile</a></li> <div class="clearfix"></div>

既然您用PHP标记了这个问题,我就假设您正在使用PHP作为服务器端逻辑。在这种情况下,PHP将在调用它的位置包含另一个PHP文件的内容。另一个文件不需要PHP代码,它可以是纯HTML

因此,您的代码可能如下所示:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <?php include "header.html"; ?>

        <!-- page-specific content goes here -->
    </body>
</html>
<object name="header" type="text/html" data="header.inc.html"></object>


这样,您只需在
header.html
文件中创建一次标题内容,并将其包含在您想要使用它的每个文件中。

既然您用PHP标记了这个问题,我将假设您使用PHP作为服务器端逻辑。在这种情况下,PHP将在调用它的位置包含另一个PHP文件的内容。另一个文件不需要PHP代码,它可以是纯HTML

因此,您的代码可能如下所示:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <?php include "header.html"; ?>

        <!-- page-specific content goes here -->
    </body>
</html>
<object name="header" type="text/html" data="header.inc.html"></object>

这样,您只需在
header.html
文件中创建一次标题内容,并将其包含在您想要使用它的每个文件中。

您可以使用以下非标准方式:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <?php include "header.html"; ?>

        <!-- page-specific content goes here -->
    </body>
</html>
<object name="header" type="text/html" data="header.inc.html"></object>
最后但并非最不重要的一点是,您可以使用框架集或iFrame作为坏习惯。

您可以使用以下非标准方式:

<!DOCTYPE html>
<html>
    <head></head>
    <body>
        <?php include "header.html"; ?>

        <!-- page-specific content goes here -->
    </body>
</html>
<object name="header" type="text/html" data="header.inc.html"></object>
最后但并非最不重要的一点是,您可以使用框架集或iFrame作为坏习惯。

如果在服务器上启用了SSI(服务器端包括),请使用它

或者,如果php在您的服务器上运行,请使用php包含函数

如果在服务器上启用了SSI(服务器端包括),请使用它

或者,如果php在您的服务器上运行,请使用php包含函数


好的……从哪里开始……我将向您展示如何创建基本的HTML5主模板

如果您还不喜欢文本编辑器,我会推荐您

第一个-创建母版页|
Master.php

<!doctype html>

<html>

<head>

  <title>My Title</title>

  <meta charset="utf-8">
  <meta name="description" content="My Website">
  <meta name="keywords" content="keyword1, keyword2, keyword3...">
  <meta name="author" content="Me">

  <link href="favicon.ico" rel="shortcut icon">

  <link href="css/style.css" rel="stylesheet" media="screen">

</head>

<body>

  <header>

    <?php include('header.html'); ?>       <!-- Put Navigation in Header -->
    <?php include('navigation.html'); ?>   <!-- Or Make Separate Navigation -->

  </header>


  <div id="content">

    <?php include($page_content); ?>       <!-- More about this in final step -->
    <?php include('sidebar.html'); ?>      <!-- Yes, you can add the sidebar too :) -->
    <div class="clearfix"></div>           <!-- Smart to put it here ;) -->

  </div>


  <footer>

    <?php include('footer.html'); ?>

  </footer>

</body>

</html>

第3步-创建
footer.html
footer.php
文档

<div>

  Some footer content here...

</div>

Anything else what we want in the footer area.
然后将新创建的
index content.php
放入文件夹
includes

然后创建新文档
index.php
并将其放入文档根文件夹

index.php
文档的内容

<?php
  $page_content = 'includes/index-content.php';
  include('master.php');
?>

现在在web浏览器中导航到
localhost/sitename/index.php
并完成
(如果您没有启动并运行localhost服务器,请在web浏览器中打开
index.php

以后创建其他页面/文档的方法与创建文档内容的方法相同,例如创建
pagename content.php
pagename content.html
,对于在导航中链接的实际页面,创建pagename.php(如上例所示),而不是在导航链接中调用它(如



现在到此为止,如果有任何添加,请在评论中询问。

好的……从哪里开始……我将向您展示如何创建基本的HTML5主模板。

如果您还不喜欢文本编辑器,我会推荐您

第一个-创建母版页|
Master.php

<!doctype html>

<html>

<head>

  <title>My Title</title>

  <meta charset="utf-8">
  <meta name="description" content="My Website">
  <meta name="keywords" content="keyword1, keyword2, keyword3...">
  <meta name="author" content="Me">

  <link href="favicon.ico" rel="shortcut icon">

  <link href="css/style.css" rel="stylesheet" media="screen">

</head>

<body>

  <header>

    <?php include('header.html'); ?>       <!-- Put Navigation in Header -->
    <?php include('navigation.html'); ?>   <!-- Or Make Separate Navigation -->

  </header>


  <div id="content">

    <?php include($page_content); ?>       <!-- More about this in final step -->
    <?php include('sidebar.html'); ?>      <!-- Yes, you can add the sidebar too :) -->
    <div class="clearfix"></div>           <!-- Smart to put it here ;) -->

  </div>


  <footer>

    <?php include('footer.html'); ?>

  </footer>

</body>

</html>

第3步-创建
footer.html
footer.php
文档

<div>

  Some footer content here...

</div>

Anything else what we want in the footer area.
然后将新创建的
index content.php
放入文件夹
includes

然后创建新文档
index.php
并将其放入文档根文件夹

index.php
文档的内容

<?php
  $page_content = 'includes/index-content.php';
  include('master.php');
?>

现在在web浏览器中导航到
localhost/sitename/index.php
并完成。
(如果您没有启动并运行localhost服务器,请在web浏览器中打开
index.php

以后创建其他页面/文档的方法与创建文档内容的方法相同,例如创建
pagename content.php
pagename content.html
,对于在导航中链接的实际页面,创建pagename.php(如上例所示),而不是在导航链接中调用它(如



现在到此为止,如果有任何补充,请在评论中询问。

作为第一个对我的帖子发表评论的人……我大约20个小时没睡,如果我忘了包含某些内容或拼写错误,请随时在评论中提及。mdesdev感谢您宝贵的评论,我已经修改了,但无法再次使用,请查看下面的内容链接我编辑了我的答案,我使用这个系统已经很多年了,我不知道我怎么会错过我第一个版本答案中的index.php(可能太累了),但是现在,一切都好了;)作为第一个在我的帖子上发表评论的人…我大约20个小时没睡,如果我忘了写东西或拼写错误,请随时在评论中提及。mdesdev感谢你的宝贵评论,我已经修改了,但它不再起作用,请检查下面的链接我编辑了我的答案,我已经使用这个系统很多年了,我不知道我怎么会错过我的答案的第1个版本中的index.php(可能太累了),但是现在,一切都好了;)我试过这样做,但菜单页面没有显示你能分享你的mai吗