我有一个网站有一个空白问题。我在doctype 之前包含了一些文件,这会导致输出一个空白区域。PHP包含()doctype之前,导致一个空白区域
搜索后,我发现这个解决方案: Problem with whitespace before doctype
但是除去?>
后,我仍然得到这个问题。下面是代码:
<?php
include ("include/session.php");
include ("include/updatestage.php");
?>
<!DOCTYPE HTML>....
这里是session.php
:
<?php session_start();
// if a team name has been assigned to a session...
if (isset($_SESSION ['teamName']))
{
//create "global variable $teamName that can be used across all pages as long as the function "session_start(); is present"
$teamName = $_SESSION ['teamName'];
}
else{
die ("You are not logged in! Redirecting to login page...<meta http-equiv='REFRESH' content='2; url = index.php'>");
}
这是updatestage.php
:
<?php
include("config.php");
//update stage
$inserted="n";
mysql_query ("UPDATE `team` SET `inserted`='$inserted' WHERE teamName = '$teamName' ");
$advance="n";
mysql_query ("UPDATE `game` SET `advance`='$advance' ");
这里是getstageinfo.php
:
<?php
include("include/config.php");
//Select the slogan from the current user
$currentStage = mysql_query("
SELECT `currentStage` FROM `team` WHERE `teamName` = '$teamName'
");
//assign the text located at the logo field (the path of the logo) to a variable $slogan
$row = mysql_fetch_assoc($currentStage);
$currentStage= $row['currentStage'];
?>
的ð终于在这里是config.php
:
<?php
// connect to database
$con = mysql_connect("xxxxxxx","xxxxxxx","xxxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// select database
mysql_select_db ("xxxxxxx");
?>
///////////////////////////////////// ////////////////////////////////////////////////// ///
好了,所以我在加回>和尝试以下建议:
<!DOCTYPE HTML>
<?php
include("include/session.php");
include("include/updatestage.php");
?>
或尝试:
<?php
echo "<!DOCTYPE HTML>\n";
include ("include/session.php");
include ("include/updatestage.php");
?>
产地:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at public_html/period1.php:2) in public_html/include/session.php on line 1
尝试:
<?php
include("include/session.php");
include("include/updatestage.php");
?><!DOCTYPE HTML>
或者:
<?php
ob_start();
echo "<!DOCTYPE HTML>\n";
include ("include/session.php");
include ("include/updatestage.php");
ob_end_flush();
?>
仍然生产的空白。
将'session.php'和'updatestage.php'复制并粘贴到纯文本编辑器(如记事本)中,然后将包复制并粘贴到文档中。另外,确保在这两个文件中''?php'开始之前或结束'?>'之后没有空格。 – Dutchie432 2012-02-03 15:41:26
发现问题,它是嵌套'include(“config.php”);'而不是包括我刚刚将代码粘贴到'updatestage.php'中 – NeverPhased 2012-02-03 15:42:41
那么问题可能是confuig中的空白。php' – Dutchie432 2012-02-03 15:43:21