关于php页面中session_start()与CSS冲突的问题
大家好,我是刚刚学习在PHP中使用css+div的新手。目前有一问题始终不能理解和解决,希望大家能帮助我!
我的index.php代码如下:
<?
include "config.inc";
include "include/rand.php";
include_once("counter/counter.php");
if(isStudent())
{
goPage("/student_study.php");
exit;
}
if(isTeacher())
{
goPage("/teacher.php");
exit;
}
if(isAdmin())
{
goPage("/adminuser/htglxt.php");//manager
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta http-equiv="Content-Language" content="English" />
<meta name="Author" content="Luka Cvrk (luka@solucija.com)" />
<meta name="Robots" content="index,follow" />
<meta name="Description" content="Artificial Intelligence" />
<meta name="Keywords" content="artificial, intelligence" />
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Artificial Intelligence</title>
</head>
<body>
<div id="main">
<div id="logo">
<h1>Yartvu <span class="blue">.net</span></h1>
中间省略
</div>
</body>
</html>
------------------------------
我的stye.css文挡如下:
/*
template: Artificial Intelligence
author: luka cvrk (www.solucija.com)
*/
body {
margin: 0;
padding: 0;
background: #fff url(images/bg.gif) repeat-x;
font: normal .7em Tahoma, Verdana, Arial, Helvetica, Sans-Serif;
line-height: 1.6em;
color: #333;
}
/* LINKS AND HEADINGS STYLING */
a { color: #546F92; background: inherit; }
a:hover { color: #808080; background: inherit; }
h1 { font: bold 2em "Trebuchet MS", Helvetica, Sans-Serif; margin: 0; color: #fff; background-color:transparent; }
h2 { font: bold 1.4em "Trebuchet MS", Helvetica, Sans-Serif; }
h3 { clear: both; font-size: 1.1em; color: #000; background: #fff url(images/h3bg.gif) no-repeat center left; padding: 0 14px; margin: 0;}
.blue { color: #546F92; background: inherit; }
.image { float: left; border: 2px solid #e2e2e2; padding: 3px; margin: 0 15px 10px 0; }
/* CONTENT WRAPPER */
#main {
width: 900px;
margin: 25px auto 0 auto;
}
/* TOP LEFT LOGO */
#logo {
float: left;
padding: 10px 0 10px 10px;
}
#logo h1 { color: #000; background: #fff; }
/* TOP RIGHT HORIZONTAL MENU */
#menu {
float: right;
中间省略
#footer { clear: both; padding: 5px; border-top: 1px solid #ccc; }
----------------------------------------
现在的问题是在index.php文挡的最前面,
如果我把<?php ?>放在最前面,那CSS就不起作用。我查了一下,好象是<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">这句必须要放在文挡最前面。
而如果我把<?php ?>放在<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">的后面,那php就会出现问题:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at index.php:2) in ..\include\public_user.inc on line 2
怎么解决这个问题呢??
------解决方案--------------------
看看有没帮助
http://hi.baidu.com/pingfandexiake/blog/item/6844090830e1d8960b7b8255.html
[解决办法]
你PHP里面的include是不是有HTML输出啊。