2014-04-06 58 views
0

下面是我的php代码包含。我想我输入正确的代码,但它似乎只是不遵守:我如何才能让PHP INCLUDE工作?

这里是我的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; 
}' 

感谢您的支持家伙。

+0

你能解释它是如何工作的吗? – aksu

+0

@aksu即使它看起来明显错误,请不要更改OP的代码。这可能实际上是OP所犯的错误。回滚到第一个版本。 –

+0

最近你执行的错误是什么? –

回答

0

这应该是地方抛出一个错误:你headertop.php

<?php 
<div id="headertop"> 

它。此外,我建议你在编码时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> 
+0

太棒了!谢谢! – ROLDANKING