include() messing up HTML structure

我是研究僧i 提交于 2019-12-12 04:38:10

问题


I have a little problem. I have header.php and footer.php files which I include in every page. In the header.php I have the <head> tag with the scripts/styles and a div which is the top bar. In the footer.php I have closing tags.

 <?php include('header.php'); ?>
    <div class="content">
       <!-- CONTENT -->
    </div>
 <?php include('footer.php'); ?>

The problem is when I structure a page like the code above, my code is messed up, here is a picture http://img13.imageshack.us/img13/9640/92571581.jpg As you can see, the whole head seaction goes inside body. If I copy paste the code from header.php and footer.php without including, everything works as it should, picture here http://img833.imageshack.us/img833/2603/98557724.jpg

What is the problem ? Every tag is opened and closed in the right place.

Thank you


回答1:


When you open a html page it loads automatically the default head. Your php code is running after that loading. Try not to use that include.



来源:https://stackoverflow.com/questions/16770039/include-messing-up-html-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!