Heim >Backend-Entwicklung >PHP-Tutorial > 怎么设置html页头

怎么设置html页头

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 12:30:182775Durchsuche

如何设置html页头

本帖最后由 dd0607 于 2014-01-06 01:42:27 编辑 index.php
<?php<br />
include("include/conn.php");<br />
include("header.php");<br />
include("footer.php");<br />
?>


conn.php
<?php <br />
$host='localhost';  <br />
$user_name='root';  <br />
$password='123123';<br />
$db='netbox';<br />
$conn = mysqli_connect($host,$user_name,$password,$db) or die("Connect failed: " . mysqli_connect_error());<br />
?><br />


header.php
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<html xmlns="http://www.w3.org/1999/xhtml"><br />
<head><br />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br />
<meta http-equiv="X-UA-Compatible" content="IE=edge" /><br />
<title>test</title><br />
<link href="/css/main.css" rel="stylesheet"><br />
</head><br />
<body><br />


footer.php
<br />
</body><br />
</html><br />


当index.php不加载conn.php,页面显示正常
当加载conn.php后,页面会自己添加html/head/body等html标签,同时去除了我header.php里的DOCTYPE/html/head,其他内容则统统丢进body里,这是什么原因造成的呢?

PS:加载conn.php后右击页面查看源码,是正常的,但显示是有问题的 会在页面顶部顶出一行空白,IE11和Chrome33按F12查看HTML代码就会发现已经不正常了



刚从ASP转PHP,ASP这样逻辑写法是没问题,不懂PHP问题出在哪里
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn