【问题标题】:How can I get PHP INCLUDE working?如何让 PHP INCLUDE 正常工作?
【发布时间】:2014-04-06 09:09:04
【问题描述】:

下面是我的 php 包含代码。我想我输入了正确的代码,但它似乎不遵守:

这是我的 headertop.php:

'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <title>HOME</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
    <meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation,    
portfolio, thumbnails"/>
    <link rel="shortcut icon" href="images/art_favicon.png" type="image/x-  
icon"/>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>
</head>


<header> 
<?php            


 <div id="headertop">

    <div id="adams">

        <p><span style="color: #F60;">A</span>ncajas <span style="color:   
#F60;">D</span>igital <span style="color: #F60;">A</span>rts &amp; <span style="color: 
#F60;">M</span>edia <span style="color: #F60;">S</span>olutions</p>

    </div>

</div>

?>     
</header> 


</head>

</html>'

这是我的 index.php:

'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"    
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
    <title>HOME</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <meta name="description" content="Slide Down Box Menu with jQuery and CSS3" />
    <meta name="keywords" content="jquery, css3, sliding, box, menu, cube, navigation, 
portfolio, thumbnails"/>
    <link rel="shortcut icon" href="images/art_favicon.png" type="image/x-
icon"/>
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"/>

    <style>

        body{
            background-image: url(images/graphy.png);
            font-family:Arial, Helvetica, sans-serif;
            margin: 0;
            padding: 0;
        }
    </style>

</head>

<header>
<?php

include ('headertop.php');

?>

</header>

<body>

<div id="contents">

</div>

</body>

</html>'

当然还有我的标题部分的 CSS:

'#headertop{
width: 1050px;
height: auto;
background-color: #252525;
margin-left: auto;
margin-right: auto;
position: inherit;  
border-top: solid #F60 2px;
margin-bottom: 0px;

/*border-bottom: solid #F60 1px;*/ 
}

#adams{
font-family:"Trajan Pro";
font-weight: 100;
font-size: 24px;
text-align: center;
color: #CCC;
padding-bottom: 6px;
margin-bottom: 17px;            
}

header{
width: 1050px;
height: 300px;
/*background-image:url(../interactive/product_slideshow.swf);*/
/*background-color: #999;*/
margin-left: auto;
margin-right: auto; 
}'

感谢大家的支持。

【问题讨论】:

  • 你能解释一下它是怎么不工作的吗?
  • @aksu 即使看起来很明显的错误,也请不要更改OP的代码。 可能实际上是 OP 所犯的错误。回滚到第一个版本。
  • 你执行的错误是什么?
  • @ICanHasCheezburger,确实这似乎不是一个错误,而是故意写在文献中,指出引用的开头和结尾。此外,CSS 在这里根本不相关,您不同意吗?

标签: php html css include


【解决方案1】:

这应该在某处抛出错误:

<?php
 <div id="headertop">

它在您的headertop.php 内。此外,我建议您在编码时turn errors on,这样就不会再发生这种情况了。

您不需要在要包含的文件中设置完整的 html,只需要设置您想要包含的部分即可。尝试将headertop.php 更改为:

<div id="headertop">
  <div id="adams">
    <p>
      <span style="color: #F60;">A</span>ncajas
      <span style="color: #F60;">D</span>igital
      <span style="color: #F60;">A</span>rts &amp;
      <span style="color: #F60;">M</span>edia
      <span style="color: #F60;">S</span>olutions
    </p>
  </div>
</div>

【讨论】:

    猜你喜欢
    • 2013-06-09
    • 2014-04-13
    • 1970-01-01
    • 2015-05-08
    • 2020-08-27
    • 2018-06-11
    • 2016-08-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多