包括()弄乱HTML结构 [英] include() messing up HTML structure

查看:134
本文介绍了包括()弄乱HTML结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小问题。我有每个页面都包含的header.php和footer.php文件。在header.php中,我有< head> 标签,脚本/样式以及顶部栏div。

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

问题是当我像上面的代码一样构造一个页面时,我的代码被搞砸了,这里是一张图片 http://img13.imageshack.us/img13/9640/92571581.jpg
正如你所看到的那样,整个头部的吸引力进入了身体内部。
如果我复制粘贴代码从header.php和footer.php不包括,一切工作,因为它应该,这里 http://img833.imageshack.us/img833/2603/98557724.jpg

问题是什么?

谢谢

解决方案

当你打开一个html页面时,它会自动加载默认头部。加载后,您的php代码正在运行。尽量不要使用包含。


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

解决方案

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.

这篇关于包括()弄乱HTML结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆