Php 说:";标题已发送";,但它没有';没有
我很困惑,我最近刚从一个本地服务器(Wamp)切换到一个实时服务器(DreamHost-Shared) 现在,我的localserver工作得很好,但在live server上,它会引发Php 说:";标题已发送";,但它没有';没有,php,Php,我很困惑,我最近刚从一个本地服务器(Wamp)切换到一个实时服务器(DreamHost-Shared) 现在,我的localserver工作得很好,但在live server上,它会引发无法修改头信息的问题。这很奇怪,因为那里什么也没有发生!有什么东西我遗漏了吗 <!DOCTYPE html> <html> <head> <?php include("/home/postinowner/postin.me/includes/head.php");
无法修改头信息的问题。这很奇怪,因为那里什么也没有发生!有什么东西我遗漏了吗
<!DOCTYPE html>
<html>
<head>
<?php include("/home/postinowner/postin.me/includes/head.php");?>
<title> Your Words, Your Thoughts, So Get POSTIN'</title>
<link type="text/css" rel="stylesheet" href="css/style.home.php.css"/>
</head>
<body>
<div id="wrapper" class="container">
<?php
//Grabbing the database connection
require("/home/postinowner/postin.me/db_connection.php");
//Starts the session
session_start();
//Grabs the user class
require("/home/postinowner/postin.me/classes.php");
//Grabs all of the categories
require("/home/postinowner/postin.me/allcategories.php");
//Grabs the header
include("/home/postinowner/postin.me/includes/header.php");
?>
另外,我不想抑制错误。您的会话\u start()
命令应始终位于每个文件的顶部。另外,如果您的代码中有任何头函数,那么任何和所有echo命令都应该在它之后,而不是之前
因此,例如:-
<?php
if(1==1)
{
header('Locatio:something.php');//should be immediately after the `if` start braces.
echo "something here";
}
?>
您的session\u start()
命令应始终位于每个文件的顶部。另外,如果您的代码中有任何头函数,那么任何和所有echo命令都应该在它之后,而不是之前
因此,例如:-
<?php
if(1==1)
{
header('Locatio:something.php');//should be immediately after the `if` start braces.
echo "something here";
}
?>
如果您没有使用会话,请删除session_start()代码>啊,最大的原因;-)如果您没有使用会话,请删除session_start()代码>啊,最大的原因;-)谢谢,这很有效。但是为什么呢?哈哈,为什么OP要“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了SO的未来访客。想告诉大家为什么他们应该尝试这个吗?至于未来的访客问题;他们当然也想知道;-)@Fred ii-老实说,伙计,你激励我在stackoverflow上更加积极:)很高兴听到@AkshayThank you,这起作用了。但是为什么呢?哈哈,为什么OP要“试试这个”?一个好的答案总是会有一个解释,说明做了什么以及为什么这样做,不仅是为了OP,而且是为了SO的未来访客。想告诉大家为什么他们应该尝试这个吗?至于未来的访客问题;他们当然也想知道;-)@弗雷德二世-老实说,伙计,你激励我在stackoverflow上更加积极:)很高兴听到@Akshay
<?php
if(1==1)
{
echo "something here";
header('Locatio:something.php');//should be immediately after the `if` start braces.
}
?>
<?php
session_start();
require("/home/postinowner/postin.me/db_connection.php");
?>
<!DOCTYPE html>
<html>
<head>
<?php include("/home/postinowner/postin.me/includes/head.php");?>
<title> Your Words, Your Thoughts, So Get POSTIN'</title>
<link type="text/css" rel="stylesheet" href="css/style.home.php.css"/>
</head>
<body>
<div id="wrapper" class="container">
<?php
//Grabs the user class
require("/home/postinowner/postin.me/classes.php");
//Grabs all of the categories
require("/home/postinowner/postin.me/allcategories.php");
//Grabs the header
include("/home/postinowner/postin.me/includes/header.php");
?>
?>