-1

我有一个网站,在那里我上传了一个index.html完全由 HTML 代码(没有 PHP)组成的网站。

我将此代码复制到一个 PHP 文件index.php中,此外,我将标头分隔到一个单独的 php 文件中。当我清理新的index.php时,我只是使用了一个include()来包含标题,如下所示:

<? include("TopNote.php"); ?>

index.html所以和之间的区别在于index.phpHTML 代码直接在index.htmlPHP 文件中,它是从一个单独的 PHP 文件中包含的。

现在index.php文件给出了一个奇怪的按钮,index.html它以我希望它显示的方式显示它。

index.html

<!doctype html>
<html lang="us">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="web/style.css">
  <link href="css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet">
  <style>
    .ui-menu { position: absolute; width: 100px; }
  </style>
  <script src="js/jquery-1.9.1.js"></script>
  <script src="js/jquery-ui-1.10.3.custom.js"></script>
  <script>
    $(function() {
      $( "#menu" ).buttonset();
      $( "#regdialog" ).dialog();
      $( "#buttonregister" ).click(function() {
        $( "#regdialog" ).dialog( "open" );
      });
    });
  </script>
</head>
<body bgcolor="#aaaaaa">
  <img src="example.lorg" alt="" style="padding-left:20px" />
  <div align="right" style="padding-right:20px">
    <div>
      <button id="StaffLogin">Staff Login</button>

      <button id="select">Select an action</button>
    </div>
    <ul>
      <li><a href="#">Log Out</a></li>
      <li id="buttonregister"><a href="#">Register</a></li>
    </ul>
  </div>  
  <form style="margin-top: 1em;">  
    <div id="menu" align="center">
      <input type="radio" id="buttonhome" name="radio" checked="checked"><label for="buttonhome">Home</label>
      <input type="radio" id="buttonforums" name="radio"><label for="buttonforums"><a href="http://example.org">Forums</a></label>
      <input type="radio" id="buttonapply" name="radio"><label for="buttonapply"><a class='fb_iframe' href="http://example.org">Apply</a></label>
      <input type="radio" id="buttonabout" name="radio"><label for="buttonabout">About Us</label>
      <input type="radio" id="select" name="radio">
    </div>
  </form>



  <br />
  <div class="ui-widget">
    <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
      <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
        <strong>Alert:</strong> The Site Is No Where Near Completed, Please go to our <a href="http://example.org/">Forums</a>
      </p>
    </div>
  </div>
  <!-- POP UP -->
  <div id="regdialog" title="Register">
    <form action="#" method="post">
      <div class="ui-widget">
        <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
          <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            Registrations are not working!
          </p>
        </div>
      </div>
      <h5>Username:</h5>
      <input type="text" name="reg_name">
      <h5>Password:</h5>
      <input type="password" name="reg_pass">
      <h5>Confirm Password:</h5>
      <input type="password" name="reg_pass_conf">
      <input type="submit">
    </form>
  </div>
</body>
</html> 

index.php

<!doctype html>
<html lang="us">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="web/style.css">
  <link href="css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet">
  <script src="js/jquery-1.9.1.js"></script>
  <script src="js/jquery-ui-1.10.3.custom.js"></script>
</head>
<body bgcolor="#aaaaaa">
  <? include("TopNote.php"); ?>
</body>
</html>

topnote.php

<!doctype html>
<html lang="us">
<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="web/style.css">
  <link href="css/smoothness/jquery-ui-1.10.3.custom.css" rel="stylesheet">
  <style>
    .ui-menu { position: absolute; width: 100px; }
  </style>
  <script src="js/jquery-1.9.1.js"></script>
  <script src="js/jquery-ui-1.10.3.custom.js"></script>
  <script>
    $(function() {
      $( "#menu" ).buttonset();
      $( "#regdialog" ).dialog();
      $( "#buttonregister" ).click(function() {
        $( "#regdialog" ).dialog( "open" );
      });
    });
  </script>
</head>
<body bgcolor="#aaaaaa">
  <img src="example.lorg" alt="" style="padding-left:20px" />
  <div align="right" style="padding-right:20px">
    <div>
      <button id="StaffLogin">Staff Login</button>

      <button id="select">Select an action</button>
    </div>
    <ul>
      <li><a href="#">Log Out</a></li>
      <li id="buttonregister"><a href="#">Register</a></li>
    </ul>
  </div>  
  <form style="margin-top: 1em;">  
    <div id="menu" align="center">
      <input type="radio" id="buttonhome" name="radio" checked="checked"><label for="buttonhome">Home</label>
      <input type="radio" id="buttonforums" name="radio"><label for="buttonforums"><a href="http://example.org">Forums</a></label>
      <input type="radio" id="buttonapply" name="radio"><label for="buttonapply"><a class='fb_iframe' href="http://example.org">Apply</a></label>
      <input type="radio" id="buttonabout" name="radio"><label for="buttonabout">About Us</label>
      <input type="radio" id="select" name="radio">
    </div>
  </form>



  <br />
  <div class="ui-widget">
    <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
      <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
        <strong>Alert:</strong> The Site Is No Where Near Completed, Please go to our <a href="http://example.org/">Forums</a>
      </p>
    </div>
  </div>
  <!-- POP UP -->
  <div id="regdialog" title="Register">
    <form action="#" method="post">
      <div class="ui-widget">
        <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
          <p>
            <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            Registrations are not working!
          </p>
        </div>
      </div>
      <h5>Username:</h5>
      <input type="text" name="reg_name">
      <h5>Password:</h5>
      <input type="password" name="reg_pass">
      <h5>Confirm Password:</h5>
      <input type="password" name="reg_pass_conf">
      <input type="submit">
    </form>
  </div>
</body>
</html>

有什么区别,我该如何解决?

4

2 回答 2

3

<html>标签内不能有<body>标签。你topnote.php不需要有 doctype、head 和所有这些东西。因为index.php已经定义了html、doctype、head、title等。

所以你topnote.php应该只包含这些元素:

<img src="http://destiny-craft.com/img/Logo_Resized.png" alt="" style="padding-left:20px" />
<div align="right" style="padding-right:20px">
  <div>
    <button id="StaffLogin">Staff Login</button>

    <button id="select">Select an action</button>
  </div>
  <ul>
    <li><a href="#">Log Out</a></li>
    <li id="buttonregister"><a href="#">Register</a></li>
  </ul>
</div>  
<form style="margin-top: 1em;">  
   <div id="menu" align="center">
            <input type="radio" id="buttonhome" name="radio" checked="checked"><label for="buttonhome">Home</label>
            <input type="radio" id="buttonforums" name="radio"><label for="buttonforums"><a href="http://forums.destiny-craft.com">Forums</a></label>
            <input type="radio" id="buttonapply" name="radio"><label for="buttonapply"><a class='fb_iframe' href="http://destiny-craft.coffeecup.com/forms/ApplyForm/">Apply</a></label>
        <input type="radio" id="buttonabout" name="radio"><label for="buttonabout">About Us</label>
        <input type="radio" id="select" name="radio">
    </div>
</form>



<br />
<div class="ui-widget">
    <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
            <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            <strong>Alert:</strong> The Site Is No Where Near Completed, Please go to our <a href="http://forums.destiny-craft.com/">Forums</a></p>
    </div>
</div>






<!-- POP UP -->
<div id="regdialog" title="Register">
<form action="#" method="post">
<div class="ui-widget">
    <div class="ui-state-error ui-corner-all" style="padding: 0 .7em;">
            <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>
            Registrations are not working!</p>
    </div>
</div>
    <h5>Username:</h5>
    <input type="text" name="reg_name">
    <h5>Password:</h5>
    <input type="password" name="reg_pass">
    <h5>Confirm Password:</h5>
    <input type="password" name="reg_pass_conf">
    <input type="submit">
</form>
</div>

并且您可以将您的<script>标签中的<head>标签移动topnote.phptopnote.php. 将它们放在结束</body>标记之前是有效且更好的做法。这可确保此时加载所有 DOM 元素。

于 2013-11-11T09:34:39.687 回答
1

topnote.php不应该有 doctype、html 和 head,因为您已经在 index.php 中添加了

避免使用 XML 投诉的短标签,如下所示

<?php include 'file.php'?>
于 2013-11-11T09:36:14.010 回答